| 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 | /* |
| 3 | * This file is part of the LibreOffice project. |
| 4 | * |
| 5 | * This Source Code Form is subject to the terms of the Mozilla Public |
| 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 | * |
| 9 | * This file incorporates work covered by the following license notice: |
| 10 | * |
| 11 | * Licensed to the Apache Software Foundation (ASF) under one or more |
| 12 | * contributor license agreements. See the NOTICE file distributed |
| 13 | * with this work for additional information regarding copyright |
| 14 | * ownership. The ASF licenses this file to you under the Apache |
| 15 | * License, Version 2.0 (the "License"); you may not use this file |
| 16 | * except in compliance with the License. You may obtain a copy of |
| 17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 18 | */ |
| 19 | |
| 20 | #include <memory> |
| 21 | #include <cstddef> |
| 22 | #include <type_traits> |
| 23 | #include <swpossizetabpage.hxx> |
| 24 | #include <svx/dlgutil.hxx> |
| 25 | #include <svx/anchorid.hxx> |
| 26 | #include <svl/intitem.hxx> |
| 27 | #include <svx/swframevalidation.hxx> |
| 28 | #include <sfx2/htmlmode.hxx> |
| 29 | #include <svx/svdview.hxx> |
| 30 | #include <svx/svdpagv.hxx> |
| 31 | #include <svx/swframeposstrings.hxx> |
| 32 | #include <svx/rectenum.hxx> |
| 33 | #include <com/sun/star/text/HoriOrientation.hpp> |
| 34 | #include <com/sun/star/text/VertOrientation.hpp> |
| 35 | #include <com/sun/star/text/RelOrientation.hpp> |
| 36 | #include <svx/svxids.hrc> |
| 37 | #include <svtools/unitconv.hxx> |
| 38 | #include <osl/diagnose.h> |
| 39 | #include <svl/grabbagitem.hxx> |
| 40 | |
| 41 | #include <bitmaps.hlst> |
| 42 | |
| 43 | using namespace ::com::sun::star::text; |
| 44 | |
| 45 | namespace { |
| 46 | |
| 47 | enum class LB; |
| 48 | |
| 49 | } |
| 50 | |
| 51 | struct FrmMap |
| 52 | { |
| 53 | SvxSwFramePosString::StringId eStrId; |
| 54 | SvxSwFramePosString::StringId eMirrorStrId; |
| 55 | short nAlign; |
| 56 | LB nLBRelations; |
| 57 | }; |
| 58 | |
| 59 | namespace { |
| 60 | |
| 61 | struct RelationMap |
| 62 | { |
| 63 | SvxSwFramePosString::StringId eStrId; |
| 64 | SvxSwFramePosString::StringId eMirrorStrId; |
| 65 | LB nLBRelation; |
| 66 | short nRelation; |
| 67 | }; |
| 68 | struct StringIdPair_Impl |
| 69 | { |
| 70 | SvxSwFramePosString::StringId eHori; |
| 71 | SvxSwFramePosString::StringId eVert; |
| 72 | }; |
| 73 | |
| 74 | enum class LB { |
| 75 | NONE = 0x000000, |
| 76 | Frame = 0x000001, // paragraph text area |
| 77 | PrintArea = 0x000002, // paragraph text area + indents |
| 78 | VertFrame = 0x000004, // vertical paragraph text area |
| 79 | VertPrintArea = 0x000008, // vertical paragraph text area + indents |
| 80 | RelFrameLeft = 0x000010, // left paragraph margin |
| 81 | RelFrameRight = 0x000020, // right paragraph margin |
| 82 | |
| 83 | RelPageLeft = 0x000040, // left page margin |
| 84 | RelPageRight = 0x000080, // right page margin |
| 85 | RelPageFrame = 0x000100, // complete page |
| 86 | RelPagePrintArea = 0x000200, // text area of page |
| 87 | |
| 88 | FlyRelPageLeft = 0x000400, // left frame margin |
| 89 | FlyRelPageRight = 0x000800, // right frame margin |
| 90 | FlyRelPageFrame = 0x001000, // complete frame |
| 91 | FlyRelPagePrintArea = 0x002000, // frame interior |
| 92 | |
| 93 | RelBase = 0x004000, // as char, relative to baseline |
| 94 | RelChar = 0x008000, // as char, relative to character |
| 95 | RelRow = 0x010000, // as char, relative to line |
| 96 | |
| 97 | // #i22305# |
| 98 | FlyVertFrame = 0x020000, // vertical entire frame |
| 99 | FlyVertPrintArea = 0x040000, // vertical frame text area |
| 100 | |
| 101 | // #i22341# |
| 102 | VertLine = 0x080000, // vertical text line |
| 103 | |
| 104 | RelPagePrintAreaBottom = 0x100000, // bottom of text area of page |
| 105 | RelPagePrintAreaTop = 0x200000, |
| 106 | |
| 107 | LAST = 0x400000 |
| 108 | }; |
| 109 | |
| 110 | } |
| 111 | |
| 112 | namespace o3tl { |
| 113 | template<> struct typed_flags<LB> : is_typed_flags<LB, 0x3fffff> {}; |
| 114 | } |
| 115 | |
| 116 | RelationMap const aRelationMap[] = |
| 117 | { |
| 118 | {SvxSwFramePosString::FRAME, SvxSwFramePosString::FRAME, LB::Frame, RelOrientation::FRAME}, |
| 119 | {SvxSwFramePosString::PRTAREA, SvxSwFramePosString::PRTAREA, LB::PrintArea, RelOrientation::PRINT_AREA}, |
| 120 | {SvxSwFramePosString::REL_PG_LEFT, SvxSwFramePosString::MIR_REL_PG_LEFT, LB::RelPageLeft, RelOrientation::PAGE_LEFT}, |
| 121 | {SvxSwFramePosString::REL_PG_RIGHT, SvxSwFramePosString::MIR_REL_PG_RIGHT, LB::RelPageRight, RelOrientation::PAGE_RIGHT}, |
| 122 | {SvxSwFramePosString::REL_FRM_LEFT, SvxSwFramePosString::MIR_REL_FRM_LEFT, LB::RelFrameLeft, RelOrientation::FRAME_LEFT}, |
| 123 | {SvxSwFramePosString::REL_FRM_RIGHT, SvxSwFramePosString::MIR_REL_FRM_RIGHT, LB::RelFrameRight, RelOrientation::FRAME_RIGHT}, |
| 124 | {SvxSwFramePosString::REL_PG_FRAME, SvxSwFramePosString::REL_PG_FRAME, LB::RelPageFrame, RelOrientation::PAGE_FRAME}, |
| 125 | {SvxSwFramePosString::REL_PG_PRTAREA,SvxSwFramePosString::REL_PG_PRTAREA, LB::RelPagePrintArea, RelOrientation::PAGE_PRINT_AREA}, |
| 126 | {SvxSwFramePosString::REL_PG_PRTAREA_TOP,SvxSwFramePosString::REL_PG_PRTAREA_TOP, LB::RelPagePrintAreaTop, RelOrientation::PAGE_PRINT_AREA_TOP}, |
| 127 | {SvxSwFramePosString::REL_PG_PRTAREA_BOTTOM,SvxSwFramePosString::REL_PG_PRTAREA_BOTTOM, LB::RelPagePrintAreaBottom, RelOrientation::PAGE_PRINT_AREA_BOTTOM}, |
| 128 | {SvxSwFramePosString::REL_CHAR, SvxSwFramePosString::REL_CHAR, LB::RelChar, RelOrientation::CHAR}, |
| 129 | |
| 130 | {SvxSwFramePosString::FLY_REL_PG_LEFT, SvxSwFramePosString::FLY_MIR_REL_PG_LEFT, LB::FlyRelPageLeft, RelOrientation::PAGE_LEFT}, |
| 131 | {SvxSwFramePosString::FLY_REL_PG_RIGHT, SvxSwFramePosString::FLY_MIR_REL_PG_RIGHT, LB::FlyRelPageRight, RelOrientation::PAGE_RIGHT}, |
| 132 | {SvxSwFramePosString::FLY_REL_PG_FRAME, SvxSwFramePosString::FLY_REL_PG_FRAME, LB::FlyRelPageFrame, RelOrientation::PAGE_FRAME}, |
| 133 | {SvxSwFramePosString::FLY_REL_PG_PRTAREA, SvxSwFramePosString::FLY_REL_PG_PRTAREA, LB::FlyRelPagePrintArea, RelOrientation::PAGE_PRINT_AREA}, |
| 134 | |
| 135 | {SvxSwFramePosString::REL_BORDER, SvxSwFramePosString::REL_BORDER, LB::VertFrame, RelOrientation::FRAME}, |
| 136 | {SvxSwFramePosString::REL_PRTAREA, SvxSwFramePosString::REL_PRTAREA, LB::VertPrintArea, RelOrientation::PRINT_AREA}, |
| 137 | |
| 138 | // #i22305# |
| 139 | {SvxSwFramePosString::FLY_REL_PG_FRAME, SvxSwFramePosString::FLY_REL_PG_FRAME, LB::FlyVertFrame, RelOrientation::FRAME}, |
| 140 | {SvxSwFramePosString::FLY_REL_PG_PRTAREA, SvxSwFramePosString::FLY_REL_PG_PRTAREA, LB::FlyVertPrintArea, RelOrientation::PRINT_AREA}, |
| 141 | |
| 142 | // #i22341# |
| 143 | {SvxSwFramePosString::REL_LINE, SvxSwFramePosString::REL_LINE, LB::VertLine, RelOrientation::TEXT_LINE} |
| 144 | }; |
| 145 | |
| 146 | RelationMap const aAsCharRelationMap[] = |
| 147 | { |
| 148 | {SvxSwFramePosString::REL_BASE, SvxSwFramePosString::REL_BASE, LB::RelBase, RelOrientation::FRAME}, |
| 149 | {SvxSwFramePosString::REL_CHAR, SvxSwFramePosString::REL_CHAR, LB::RelChar, RelOrientation::FRAME}, |
| 150 | {SvxSwFramePosString::REL_ROW, SvxSwFramePosString::REL_ROW, LB::RelRow, RelOrientation::FRAME} |
| 151 | }; |
| 152 | |
| 153 | /*-------------------------------------------------------------------- |
| 154 | Anchored at page |
| 155 | --------------------------------------------------------------------*/ |
| 156 | |
| 157 | constexpr auto HORI_PAGE_REL = LB::RelPageFrame|LB::RelPagePrintArea|LB::RelPageLeft| |
| 158 | LB::RelPageRight; |
| 159 | |
| 160 | FrmMap const aHPageMap[] = |
| 161 | { |
| 162 | {SvxSwFramePosString::LEFT, SvxSwFramePosString::MIR_LEFT, HoriOrientation::LEFT, HORI_PAGE_REL}, |
| 163 | {SvxSwFramePosString::RIGHT, SvxSwFramePosString::MIR_RIGHT, HoriOrientation::RIGHT, HORI_PAGE_REL}, |
| 164 | {SvxSwFramePosString::CENTER_HORI,SvxSwFramePosString::CENTER_HORI, HoriOrientation::CENTER, HORI_PAGE_REL}, |
| 165 | {SvxSwFramePosString::FROMLEFT, SvxSwFramePosString::MIR_FROMLEFT, HoriOrientation::NONE, HORI_PAGE_REL} |
| 166 | }; |
| 167 | |
| 168 | FrmMap const aHPageHtmlMap[] = |
| 169 | { |
| 170 | {SvxSwFramePosString::FROMLEFT, SvxSwFramePosString::MIR_FROMLEFT, HoriOrientation::NONE, LB::RelPageFrame} |
| 171 | }; |
| 172 | |
| 173 | #define VERT_PAGE_REL (LB::RelPageFrame|LB::RelPagePrintArea) |
| 174 | |
| 175 | FrmMap const aVPageMap[] = |
| 176 | { |
| 177 | {SvxSwFramePosString::TOP, SvxSwFramePosString::TOP, VertOrientation::TOP, VERT_PAGE_REL}, |
| 178 | {SvxSwFramePosString::BOTTOM, SvxSwFramePosString::BOTTOM, VertOrientation::BOTTOM, VERT_PAGE_REL}, |
| 179 | {SvxSwFramePosString::CENTER_VERT, SvxSwFramePosString::CENTER_VERT, VertOrientation::CENTER, VERT_PAGE_REL}, |
| 180 | {SvxSwFramePosString::FROMTOP, SvxSwFramePosString::FROMTOP, VertOrientation::NONE, VERT_PAGE_REL} |
| 181 | }; |
| 182 | |
| 183 | FrmMap const aVPageHtmlMap[] = |
| 184 | { |
| 185 | {SvxSwFramePosString::FROMTOP, SvxSwFramePosString::FROMTOP, VertOrientation::NONE, LB::RelPageFrame} |
| 186 | }; |
| 187 | |
| 188 | /*-------------------------------------------------------------------- |
| 189 | Anchored at frame |
| 190 | --------------------------------------------------------------------*/ |
| 191 | |
| 192 | constexpr auto HORI_FRAME_REL = LB::FlyRelPageFrame|LB::FlyRelPagePrintArea| |
| 193 | LB::FlyRelPageLeft|LB::FlyRelPageRight; |
| 194 | |
| 195 | FrmMap const aHFrameMap[] = |
| 196 | { |
| 197 | {SvxSwFramePosString::LEFT, SvxSwFramePosString::MIR_LEFT, HoriOrientation::LEFT, HORI_FRAME_REL}, |
| 198 | {SvxSwFramePosString::RIGHT, SvxSwFramePosString::MIR_RIGHT, HoriOrientation::RIGHT, HORI_FRAME_REL}, |
| 199 | {SvxSwFramePosString::CENTER_HORI, SvxSwFramePosString::CENTER_HORI, HoriOrientation::CENTER, HORI_FRAME_REL}, |
| 200 | {SvxSwFramePosString::FROMLEFT, SvxSwFramePosString::MIR_FROMLEFT, HoriOrientation::NONE, HORI_FRAME_REL} |
| 201 | }; |
| 202 | |
| 203 | FrmMap const aHFlyHtmlMap[] = |
| 204 | { |
| 205 | {SvxSwFramePosString::LEFT, SvxSwFramePosString::MIR_LEFT, HoriOrientation::LEFT, LB::FlyRelPageFrame}, |
| 206 | {SvxSwFramePosString::FROMLEFT, SvxSwFramePosString::MIR_FROMLEFT, HoriOrientation::NONE, LB::FlyRelPageFrame} |
| 207 | }; |
| 208 | |
| 209 | // #i18732# - own vertical alignment map for to frame anchored objects |
| 210 | // #i22305# |
| 211 | #define VERT_FRAME_REL (LB::FlyVertFrame|LB::FlyVertPrintArea) |
| 212 | |
| 213 | FrmMap const aVFrameMap[] = |
| 214 | { |
| 215 | {SvxSwFramePosString::TOP, SvxSwFramePosString::TOP, VertOrientation::TOP, VERT_FRAME_REL}, |
| 216 | {SvxSwFramePosString::BOTTOM, SvxSwFramePosString::BOTTOM, VertOrientation::BOTTOM, VERT_FRAME_REL}, |
| 217 | {SvxSwFramePosString::CENTER_VERT, SvxSwFramePosString::CENTER_VERT, VertOrientation::CENTER, VERT_FRAME_REL}, |
| 218 | {SvxSwFramePosString::FROMTOP, SvxSwFramePosString::FROMTOP, VertOrientation::NONE, VERT_FRAME_REL} |
| 219 | }; |
| 220 | |
| 221 | FrmMap const aVFlyHtmlMap[] = |
| 222 | { |
| 223 | {SvxSwFramePosString::TOP, SvxSwFramePosString::TOP, VertOrientation::TOP, LB::FlyVertFrame}, |
| 224 | {SvxSwFramePosString::FROMTOP, SvxSwFramePosString::FROMTOP, VertOrientation::NONE, LB::FlyVertFrame} |
| 225 | }; |
| 226 | |
| 227 | FrmMap const aVMultiSelectionMap[] = |
| 228 | { |
| 229 | {SvxSwFramePosString::FROMTOP, SvxSwFramePosString::FROMTOP, VertOrientation::NONE, LB::NONE} |
| 230 | }; |
| 231 | FrmMap const aHMultiSelectionMap[] = |
| 232 | { |
| 233 | {SvxSwFramePosString::FROMLEFT, SvxSwFramePosString::FROMLEFT, HoriOrientation::NONE, LB::NONE} |
| 234 | }; |
| 235 | |
| 236 | /*-------------------------------------------------------------------- |
| 237 | Anchored at paragraph |
| 238 | --------------------------------------------------------------------*/ |
| 239 | |
| 240 | constexpr auto HORI_PARA_REL = LB::Frame|LB::PrintArea|LB::RelPageLeft|LB::RelPageRight| |
| 241 | LB::RelPageFrame|LB::RelPagePrintArea|LB::RelFrameLeft| |
| 242 | LB::RelFrameRight; |
| 243 | |
| 244 | FrmMap const aHParaMap[] = |
| 245 | { |
| 246 | {SvxSwFramePosString::LEFT, SvxSwFramePosString::MIR_LEFT, HoriOrientation::LEFT, HORI_PARA_REL}, |
| 247 | {SvxSwFramePosString::RIGHT, SvxSwFramePosString::MIR_RIGHT, HoriOrientation::RIGHT, HORI_PARA_REL}, |
| 248 | {SvxSwFramePosString::CENTER_HORI, SvxSwFramePosString::CENTER_HORI, HoriOrientation::CENTER, HORI_PARA_REL}, |
| 249 | {SvxSwFramePosString::FROMLEFT, SvxSwFramePosString::MIR_FROMLEFT, HoriOrientation::NONE, HORI_PARA_REL} |
| 250 | }; |
| 251 | |
| 252 | #define HTML_HORI_PARA_REL (LB::Frame|LB::PrintArea) |
| 253 | |
| 254 | FrmMap const aHParaHtmlMap[] = |
| 255 | { |
| 256 | {SvxSwFramePosString::LEFT, SvxSwFramePosString::LEFT, HoriOrientation::LEFT, HTML_HORI_PARA_REL}, |
| 257 | {SvxSwFramePosString::RIGHT, SvxSwFramePosString::RIGHT, HoriOrientation::RIGHT, HTML_HORI_PARA_REL} |
| 258 | }; |
| 259 | |
| 260 | FrmMap const aHParaHtmlAbsMap[] = |
| 261 | { |
| 262 | {SvxSwFramePosString::LEFT, SvxSwFramePosString::MIR_LEFT, HoriOrientation::LEFT, HTML_HORI_PARA_REL}, |
| 263 | {SvxSwFramePosString::RIGHT, SvxSwFramePosString::MIR_RIGHT, HoriOrientation::RIGHT, HTML_HORI_PARA_REL} |
| 264 | }; |
| 265 | |
| 266 | |
| 267 | constexpr auto VERT_PARA_REL = LB::VertFrame|LB::VertPrintArea| |
| 268 | LB::RelPageFrame|LB::RelPagePrintArea| LB::RelPagePrintAreaTop |LB::RelPagePrintAreaBottom; |
| 269 | |
| 270 | FrmMap const aVParaMap[] = |
| 271 | { |
| 272 | {SvxSwFramePosString::TOP, SvxSwFramePosString::TOP, VertOrientation::TOP, VERT_PARA_REL}, |
| 273 | {SvxSwFramePosString::BOTTOM, SvxSwFramePosString::BOTTOM, VertOrientation::BOTTOM, VERT_PARA_REL}, |
| 274 | {SvxSwFramePosString::CENTER_VERT, SvxSwFramePosString::CENTER_VERT, VertOrientation::CENTER, VERT_PARA_REL}, |
| 275 | {SvxSwFramePosString::FROMTOP, SvxSwFramePosString::FROMTOP, VertOrientation::NONE, VERT_PARA_REL} |
| 276 | }; |
| 277 | |
| 278 | FrmMap const aVParaHtmlMap[] = |
| 279 | { |
| 280 | {SvxSwFramePosString::TOP, SvxSwFramePosString::TOP, VertOrientation::TOP, LB::VertPrintArea} |
| 281 | }; |
| 282 | |
| 283 | /*-------------------------------------------------------------------- |
| 284 | Anchored at character |
| 285 | --------------------------------------------------------------------*/ |
| 286 | |
| 287 | constexpr auto HORI_CHAR_REL = LB::Frame|LB::PrintArea|LB::RelPageLeft|LB::RelPageRight| |
| 288 | LB::RelPageFrame|LB::RelPagePrintArea|LB::RelFrameLeft| |
| 289 | LB::RelFrameRight|LB::RelChar; |
| 290 | |
| 291 | const FrmMap aHCharMap[] = |
| 292 | { |
| 293 | {SvxSwFramePosString::LEFT, SvxSwFramePosString::MIR_LEFT, HoriOrientation::LEFT, HORI_CHAR_REL}, |
| 294 | {SvxSwFramePosString::RIGHT, SvxSwFramePosString::MIR_RIGHT, HoriOrientation::RIGHT, HORI_CHAR_REL}, |
| 295 | {SvxSwFramePosString::CENTER_HORI, SvxSwFramePosString::CENTER_HORI, HoriOrientation::CENTER, HORI_CHAR_REL}, |
| 296 | {SvxSwFramePosString::FROMLEFT, SvxSwFramePosString::MIR_FROMLEFT, HoriOrientation::NONE, HORI_CHAR_REL} |
| 297 | }; |
| 298 | |
| 299 | #define HTML_HORI_CHAR_REL (LB::Frame|LB::PrintArea|LB::RelChar) |
| 300 | |
| 301 | const FrmMap aHCharHtmlMap[] = |
| 302 | { |
| 303 | {SvxSwFramePosString::LEFT, SvxSwFramePosString::LEFT, HoriOrientation::LEFT, HTML_HORI_CHAR_REL}, |
| 304 | {SvxSwFramePosString::RIGHT, SvxSwFramePosString::RIGHT, HoriOrientation::RIGHT, HTML_HORI_CHAR_REL} |
| 305 | }; |
| 306 | |
| 307 | const FrmMap aHCharHtmlAbsMap[] = |
| 308 | { |
| 309 | {SvxSwFramePosString::LEFT, SvxSwFramePosString::MIR_LEFT, HoriOrientation::LEFT, LB::PrintArea|LB::RelChar}, |
| 310 | {SvxSwFramePosString::RIGHT, SvxSwFramePosString::MIR_RIGHT, HoriOrientation::RIGHT, LB::PrintArea}, |
| 311 | {SvxSwFramePosString::FROMLEFT, SvxSwFramePosString::MIR_FROMLEFT, HoriOrientation::NONE, LB::RelPageFrame} |
| 312 | }; |
| 313 | |
| 314 | // #i18732# - allow vertical alignment at page areas |
| 315 | // #i22341# - handle <LB::RelChar> on its own |
| 316 | constexpr auto VERT_CHAR_REL = LB::VertFrame|LB::VertPrintArea| |
| 317 | LB::RelPageFrame|LB::RelPagePrintArea|LB::RelPagePrintAreaBottom; |
| 318 | |
| 319 | const FrmMap aVCharMap[] = |
| 320 | { |
| 321 | // #i22341# |
| 322 | // introduce mappings for new vertical alignment at top of line <LB::VertLine> |
| 323 | // and correct mapping for vertical alignment at character for position <FROM_BOTTOM> |
| 324 | // Note: because of these adjustments the map becomes ambiguous in its values |
| 325 | // <eStrId>/<eMirrorStrId> and <nAlign>. These ambiguities are considered |
| 326 | // in the methods <SwFrmPage::FillRelLB(..)>, <SwFrmPage::GetAlignment(..)> |
| 327 | // and <SwFrmPage::FillPosLB(..)> |
| 328 | {SvxSwFramePosString::TOP, SvxSwFramePosString::TOP, VertOrientation::TOP, VERT_CHAR_REL|LB::RelChar}, |
| 329 | {SvxSwFramePosString::BOTTOM, SvxSwFramePosString::BOTTOM, VertOrientation::BOTTOM, VERT_CHAR_REL|LB::RelChar}, |
| 330 | {SvxSwFramePosString::BELOW, SvxSwFramePosString::BELOW, VertOrientation::CHAR_BOTTOM, LB::RelChar}, |
| 331 | {SvxSwFramePosString::CENTER_VERT, SvxSwFramePosString::CENTER_VERT, VertOrientation::CENTER, VERT_CHAR_REL|LB::RelChar}, |
| 332 | {SvxSwFramePosString::FROMTOP, SvxSwFramePosString::FROMTOP, VertOrientation::NONE, VERT_CHAR_REL}, |
| 333 | {SvxSwFramePosString::FROMBOTTOM, SvxSwFramePosString::FROMBOTTOM, VertOrientation::NONE, LB::RelChar|LB::VertLine}, |
| 334 | {SvxSwFramePosString::TOP, SvxSwFramePosString::TOP, VertOrientation::LINE_TOP, LB::VertLine}, |
| 335 | {SvxSwFramePosString::BOTTOM, SvxSwFramePosString::BOTTOM, VertOrientation::LINE_BOTTOM, LB::VertLine}, |
| 336 | {SvxSwFramePosString::CENTER_VERT, SvxSwFramePosString::CENTER_VERT, VertOrientation::LINE_CENTER, LB::VertLine} |
| 337 | }; |
| 338 | |
| 339 | |
| 340 | FrmMap const aVCharHtmlMap[] = |
| 341 | { |
| 342 | {SvxSwFramePosString::BELOW, SvxSwFramePosString::BELOW, VertOrientation::CHAR_BOTTOM, LB::RelChar} |
| 343 | }; |
| 344 | |
| 345 | FrmMap const aVCharHtmlAbsMap[] = |
| 346 | { |
| 347 | {SvxSwFramePosString::TOP, SvxSwFramePosString::TOP, VertOrientation::TOP, LB::RelChar}, |
| 348 | {SvxSwFramePosString::BELOW, SvxSwFramePosString::BELOW, VertOrientation::CHAR_BOTTOM, LB::RelChar} |
| 349 | }; |
| 350 | /*-------------------------------------------------------------------- |
| 351 | anchored as character |
| 352 | --------------------------------------------------------------------*/ |
| 353 | |
| 354 | FrmMap const aVAsCharMap[] = |
| 355 | { |
| 356 | {SvxSwFramePosString::TOP, SvxSwFramePosString::TOP, VertOrientation::TOP, LB::RelBase}, |
| 357 | {SvxSwFramePosString::BOTTOM, SvxSwFramePosString::BOTTOM, VertOrientation::BOTTOM, LB::RelBase}, |
| 358 | {SvxSwFramePosString::CENTER_VERT, SvxSwFramePosString::CENTER_VERT, VertOrientation::CENTER, LB::RelBase}, |
| 359 | |
| 360 | {SvxSwFramePosString::TOP, SvxSwFramePosString::TOP, VertOrientation::CHAR_TOP, LB::RelChar}, |
| 361 | {SvxSwFramePosString::BOTTOM, SvxSwFramePosString::BOTTOM, VertOrientation::CHAR_BOTTOM, LB::RelChar}, |
| 362 | {SvxSwFramePosString::CENTER_VERT, SvxSwFramePosString::CENTER_VERT, VertOrientation::CHAR_CENTER, LB::RelChar}, |
| 363 | |
| 364 | {SvxSwFramePosString::TOP, SvxSwFramePosString::TOP, VertOrientation::LINE_TOP, LB::RelRow}, |
| 365 | {SvxSwFramePosString::BOTTOM, SvxSwFramePosString::BOTTOM, VertOrientation::LINE_BOTTOM, LB::RelRow}, |
| 366 | {SvxSwFramePosString::CENTER_VERT, SvxSwFramePosString::CENTER_VERT, VertOrientation::LINE_CENTER, LB::RelRow}, |
| 367 | |
| 368 | {SvxSwFramePosString::FROMBOTTOM, SvxSwFramePosString::FROMBOTTOM, VertOrientation::NONE, LB::RelBase} |
| 369 | }; |
| 370 | |
| 371 | FrmMap const aVAsCharHtmlMap[] = |
| 372 | { |
| 373 | {SvxSwFramePosString::TOP, SvxSwFramePosString::TOP, VertOrientation::TOP, LB::RelBase}, |
| 374 | {SvxSwFramePosString::CENTER_VERT, SvxSwFramePosString::CENTER_VERT, VertOrientation::CENTER, LB::RelBase}, |
| 375 | |
| 376 | {SvxSwFramePosString::TOP, SvxSwFramePosString::TOP, VertOrientation::CHAR_TOP, LB::RelChar}, |
| 377 | |
| 378 | {SvxSwFramePosString::TOP, SvxSwFramePosString::TOP, VertOrientation::LINE_TOP, LB::RelRow}, |
| 379 | {SvxSwFramePosString::BOTTOM, SvxSwFramePosString::BOTTOM, VertOrientation::LINE_BOTTOM, LB::RelRow}, |
| 380 | {SvxSwFramePosString::CENTER_VERT, SvxSwFramePosString::CENTER_VERT, VertOrientation::LINE_CENTER, LB::RelRow} |
| 381 | }; |
| 382 | |
| 383 | static std::size_t lcl_GetFrmMapCount(const FrmMap* pMap) |
| 384 | { |
| 385 | if( !pMap ) |
| 386 | return 0; |
| 387 | |
| 388 | if( pMap == aVParaHtmlMap ) |
| 389 | return std::size(aVParaHtmlMap); |
| 390 | if( pMap == aVAsCharHtmlMap ) |
| 391 | return std::size( aVAsCharHtmlMap ); |
| 392 | if( pMap == aHParaHtmlMap ) |
| 393 | return std::size( aHParaHtmlMap ); |
| 394 | if( pMap == aHParaHtmlAbsMap ) |
| 395 | return std::size( aHParaHtmlAbsMap ); |
| 396 | if( pMap == aVPageMap ) |
| 397 | return std::size( aVPageMap ); |
| 398 | if( pMap == aVPageHtmlMap ) |
| 399 | return std::size( aVPageHtmlMap ); |
| 400 | if( pMap == aVAsCharMap ) |
| 401 | return std::size( aVAsCharMap ); |
| 402 | if( pMap == aVParaMap ) |
| 403 | return std::size( aVParaMap ); |
| 404 | if( pMap == aHParaMap ) |
| 405 | return std::size( aHParaMap ); |
| 406 | if( pMap == aHFrameMap ) |
| 407 | return std::size( aHFrameMap ); |
| 408 | if( pMap == aVFrameMap ) |
| 409 | return std::size( aVFrameMap ); |
| 410 | if( pMap == aHCharMap ) |
| 411 | return std::size( aHCharMap ); |
| 412 | if( pMap == aHCharHtmlMap ) |
| 413 | return std::size( aHCharHtmlMap ); |
| 414 | if( pMap == aHCharHtmlAbsMap ) |
| 415 | return std::size( aHCharHtmlAbsMap ); |
| 416 | if( pMap == aVCharMap ) |
| 417 | return std::size( aVCharMap ); |
| 418 | if( pMap == aVCharHtmlMap ) |
| 419 | return std::size( aVCharHtmlMap ); |
| 420 | if( pMap == aVCharHtmlAbsMap ) |
| 421 | return std::size( aVCharHtmlAbsMap ); |
| 422 | if( pMap == aHPageHtmlMap ) |
| 423 | return std::size( aHPageHtmlMap ); |
| 424 | if( pMap == aHFlyHtmlMap ) |
| 425 | return std::size( aHFlyHtmlMap ); |
| 426 | if( pMap == aVFlyHtmlMap ) |
| 427 | return std::size( aVFlyHtmlMap ); |
| 428 | if( pMap == aVMultiSelectionMap ) |
| 429 | return std::size( aVMultiSelectionMap ); |
| 430 | if( pMap == aHMultiSelectionMap ) |
| 431 | return std::size( aHMultiSelectionMap ); |
| 432 | return std::size(aHPageMap); |
| 433 | } |
| 434 | |
| 435 | static SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL( |
| 436 | SvxSwFramePosString::StringId eStringId, bool bVertical, bool bRTL, bool bDontMirrorRTL) |
| 437 | { |
| 438 | //special handling of STR_FROMLEFT |
| 439 | if(SvxSwFramePosString::FROMLEFT == eStringId) |
| 440 | { |
| 441 | bool bMirrorRtlDrawObjs = !bDontMirrorRTL; |
| 442 | bool bSwapLR = bRTL && bMirrorRtlDrawObjs; |
| 443 | eStringId = bVertical ? |
| 444 | bRTL ? SvxSwFramePosString::FROMBOTTOM : SvxSwFramePosString::FROMTOP : |
| 445 | bSwapLR ? SvxSwFramePosString::FROMRIGHT : SvxSwFramePosString::FROMLEFT; |
| 446 | return eStringId; |
| 447 | } |
| 448 | if(bVertical) |
| 449 | { |
| 450 | //exchange horizontal strings with vertical strings and vice versa |
| 451 | static const StringIdPair_Impl aHoriIds[] = |
| 452 | { |
| 453 | {SvxSwFramePosString::LEFT, SvxSwFramePosString::TOP}, |
| 454 | {SvxSwFramePosString::RIGHT, SvxSwFramePosString::BOTTOM}, |
| 455 | {SvxSwFramePosString::CENTER_HORI, SvxSwFramePosString::CENTER_VERT}, |
| 456 | {SvxSwFramePosString::FROMTOP, SvxSwFramePosString::FROMRIGHT}, |
| 457 | {SvxSwFramePosString::REL_PG_LEFT, SvxSwFramePosString::REL_PG_TOP}, |
| 458 | {SvxSwFramePosString::REL_PG_RIGHT, SvxSwFramePosString::REL_PG_BOTTOM} , |
| 459 | {SvxSwFramePosString::REL_FRM_LEFT, SvxSwFramePosString::REL_FRM_TOP}, |
| 460 | {SvxSwFramePosString::REL_FRM_RIGHT, SvxSwFramePosString::REL_FRM_BOTTOM} |
| 461 | }; |
| 462 | static const StringIdPair_Impl aVertIds[] = |
| 463 | { |
| 464 | {SvxSwFramePosString::TOP, SvxSwFramePosString::RIGHT}, |
| 465 | {SvxSwFramePosString::BOTTOM, SvxSwFramePosString::LEFT }, |
| 466 | {SvxSwFramePosString::CENTER_VERT, SvxSwFramePosString::CENTER_HORI}, |
| 467 | {SvxSwFramePosString::FROMTOP, SvxSwFramePosString::FROMRIGHT }, |
| 468 | {SvxSwFramePosString::REL_PG_TOP, SvxSwFramePosString::REL_PG_LEFT }, |
| 469 | {SvxSwFramePosString::REL_PG_BOTTOM, SvxSwFramePosString::REL_PG_RIGHT } , |
| 470 | {SvxSwFramePosString::REL_FRM_TOP, SvxSwFramePosString::REL_FRM_LEFT }, |
| 471 | {SvxSwFramePosString::REL_FRM_BOTTOM, SvxSwFramePosString::REL_FRM_RIGHT } |
| 472 | }; |
| 473 | for(const auto &a : aHoriIds) |
| 474 | { |
| 475 | if(a.eHori == eStringId) |
| 476 | { |
| 477 | eStringId = a.eVert; |
| 478 | return eStringId; |
| 479 | } |
| 480 | } |
| 481 | for(const auto &a : aVertIds) |
| 482 | { |
| 483 | if(a.eHori == eStringId) |
| 484 | { |
| 485 | eStringId = a.eVert; |
| 486 | break; |
| 487 | } |
| 488 | } |
| 489 | } |
| 490 | return eStringId; |
| 491 | } |
| 492 | // #i22341# - helper method in order to determine all possible |
| 493 | // listbox relations in a relation map for a given relation |
| 494 | static LB lcl_GetLBRelationsForRelations( const sal_uInt16 _nRel ) |
| 495 | { |
| 496 | LB nLBRelations = LB::NONE; |
| 497 | |
| 498 | for (RelationMap const & nRelMapPos : aRelationMap) |
| 499 | { |
| 500 | if ( nRelMapPos.nRelation == _nRel ) |
| 501 | { |
| 502 | nLBRelations |= nRelMapPos.nLBRelation; |
| 503 | } |
| 504 | } |
| 505 | |
| 506 | return nLBRelations; |
| 507 | } |
| 508 | |
| 509 | // #i22341# - helper method on order to determine all possible |
| 510 | // listbox relations in a relation map for a given string ID |
| 511 | static LB lcl_GetLBRelationsForStrID(const FrmMap* _pMap, |
| 512 | const SvxSwFramePosString::StringId _eStrId, |
| 513 | const bool _bUseMirrorStr ) |
| 514 | { |
| 515 | LB nLBRelations = LB::NONE; |
| 516 | |
| 517 | std::size_t nRelMapSize = lcl_GetFrmMapCount( _pMap ); |
| 518 | for ( std::size_t nRelMapPos = 0; nRelMapPos < nRelMapSize; ++nRelMapPos ) |
| 519 | { |
| 520 | if ( ( !_bUseMirrorStr && _pMap[nRelMapPos].eStrId == _eStrId ) || |
| 521 | ( _bUseMirrorStr && _pMap[nRelMapPos].eMirrorStrId == _eStrId ) ) |
| 522 | { |
| 523 | nLBRelations |= _pMap[nRelMapPos].nLBRelations; |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | return nLBRelations; |
| 528 | } |
| 529 | |
| 530 | SvxSwPosSizeTabPage::SvxSwPosSizeTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) |
| 531 | : SfxTabPage(pPage, pController, u"cui/ui/swpossizepage.ui"_ustr, u"SwPosSizePage"_ustr, &rInAttrs) |
| 532 | , m_pVMap(nullptr) |
| 533 | , m_pHMap(nullptr) |
| 534 | , m_pSdrView(nullptr) |
| 535 | , m_nOldH(HoriOrientation::CENTER) |
| 536 | , m_nOldHRel(RelOrientation::FRAME) |
| 537 | , m_nOldV(VertOrientation::TOP) |
| 538 | , m_nOldVRel(RelOrientation::PRINT_AREA) |
| 539 | , m_fWidthHeightRatio(1.0) |
| 540 | , m_bHtmlMode(false) |
| 541 | , m_bIsVerticalFrame(false) |
| 542 | , m_bPositioningDisabled(false) |
| 543 | , m_bIsMultiSelection(false) |
| 544 | , m_bIsInRightToLeft(false) |
| 545 | , m_nProtectSizeState(TRISTATE_FALSE) |
| 546 | , m_aRatioTop(ConnectorType::Top) |
| 547 | , m_aRatioBottom(ConnectorType::Bottom) |
| 548 | , m_xWidthMF(m_xBuilder->weld_metric_spin_button(u"width"_ustr, FieldUnit::CM)) |
| 549 | , m_xHeightMF(m_xBuilder->weld_metric_spin_button(u"height"_ustr, FieldUnit::CM)) |
| 550 | , m_xKeepRatioCB(m_xBuilder->weld_check_button(u"ratio"_ustr)) |
| 551 | , m_xCbxScaleImg(m_xBuilder->weld_image(u"imRatio"_ustr)) |
| 552 | , m_xImgRatioTop(new weld::CustomWeld(*m_xBuilder, u"daRatioTop"_ustr, m_aRatioTop)) |
| 553 | , m_xImgRatioBottom(new weld::CustomWeld(*m_xBuilder, u"daRatioBottom"_ustr, m_aRatioBottom)) |
| 554 | , m_xToPageRB(m_xBuilder->weld_radio_button(u"topage"_ustr)) |
| 555 | , m_xToParaRB(m_xBuilder->weld_radio_button(u"topara"_ustr)) |
| 556 | , m_xToCharRB(m_xBuilder->weld_radio_button(u"tochar"_ustr)) |
| 557 | , m_xAsCharRB(m_xBuilder->weld_radio_button(u"aschar"_ustr)) |
| 558 | , m_xToFrameRB(m_xBuilder->weld_radio_button(u"toframe"_ustr)) |
| 559 | , m_xPositionCB(m_xBuilder->weld_check_button(u"pos"_ustr)) |
| 560 | , m_xSizeCB(m_xBuilder->weld_check_button(u"size"_ustr)) |
| 561 | , m_xPosFrame(m_xBuilder->weld_widget(u"posframe"_ustr)) |
| 562 | , m_xHoriFT(m_xBuilder->weld_label(u"horiposft"_ustr)) |
| 563 | , m_xHoriLB(m_xBuilder->weld_combo_box(u"horipos"_ustr)) |
| 564 | , m_xHoriByFT(m_xBuilder->weld_label(u"horibyft"_ustr)) |
| 565 | , m_xHoriByMF(m_xBuilder->weld_metric_spin_button(u"byhori"_ustr, FieldUnit::CM)) |
| 566 | , m_xHoriToFT(m_xBuilder->weld_label(u"horitoft"_ustr)) |
| 567 | , m_xHoriToLB(m_xBuilder->weld_combo_box(u"horianchor"_ustr)) |
| 568 | , m_xHoriMirrorCB(m_xBuilder->weld_check_button(u"mirror"_ustr)) |
| 569 | , m_xVertFT(m_xBuilder->weld_label(u"vertposft"_ustr)) |
| 570 | , m_xVertLB(m_xBuilder->weld_combo_box(u"vertpos"_ustr)) |
| 571 | , m_xVertByFT(m_xBuilder->weld_label(u"vertbyft"_ustr)) |
| 572 | , m_xVertByMF(m_xBuilder->weld_metric_spin_button(u"byvert"_ustr, FieldUnit::CM)) |
| 573 | , m_xVertToFT(m_xBuilder->weld_label(u"verttoft"_ustr)) |
| 574 | , m_xVertToLB(m_xBuilder->weld_combo_box(u"vertanchor"_ustr)) |
| 575 | , m_xFollowCB(m_xBuilder->weld_check_button(u"followtextflow"_ustr)) |
| 576 | , m_xExampleWN(new weld::CustomWeld(*m_xBuilder, u"preview"_ustr, m_aExampleWN)) |
| 577 | { |
| 578 | setOptimalFrmWidth(); |
| 579 | setOptimalRelWidth(); |
| 580 | |
| 581 | FieldUnit eDlgUnit = GetModuleFieldUnit( rInAttrs ); |
| 582 | SetFieldUnit(*m_xHoriByMF, eDlgUnit, true); |
| 583 | SetFieldUnit(*m_xVertByMF, eDlgUnit, true); |
| 584 | SetFieldUnit(*m_xWidthMF , eDlgUnit, true); |
| 585 | SetFieldUnit(*m_xHeightMF, eDlgUnit, true); |
| 586 | |
| 587 | // vertical alignment = fill makes the drawingarea expand the associated spinedits so we have to size it here |
| 588 | const sal_Int16 aHeight |
| 589 | = static_cast<sal_Int16>(std::max(int(m_xKeepRatioCB->get_preferred_size().getHeight() / 2 |
| 590 | - m_xWidthMF->get_preferred_size().getHeight() / 2), |
| 591 | 12)); |
| 592 | const sal_Int16 aWidth |
| 593 | = static_cast<sal_Int16>(m_xKeepRatioCB->get_preferred_size().getWidth() / 2); |
| 594 | m_xImgRatioTop->set_size_request(aWidth, aHeight); |
| 595 | m_xImgRatioBottom->set_size_request(aWidth, aHeight); |
| 596 | //init needed for gtk3 |
| 597 | m_xCbxScaleImg->set_from_icon_name(m_xKeepRatioCB->get_active() ? RID_SVXBMP_LOCKED |
| 598 | : RID_SVXBMP_UNLOCKED); |
| 599 | m_xKeepRatioCB->connect_toggled(LINK(this, SvxSwPosSizeTabPage, RatioHdl_Impl)); |
| 600 | |
| 601 | SetExchangeSupport(); |
| 602 | |
| 603 | Link<weld::Widget&,void> aLk3 = LINK(this, SvxSwPosSizeTabPage, RangeModifyHdl); |
| 604 | m_xWidthMF->connect_focus_out(aLk3); |
| 605 | m_xHeightMF->connect_focus_out(aLk3); |
| 606 | m_xHoriByMF->connect_focus_out(aLk3); |
| 607 | m_xVertByMF->connect_focus_out(aLk3); |
| 608 | m_xFollowCB->connect_toggled(LINK(this, SvxSwPosSizeTabPage, RangeModifyClickHdl)); |
| 609 | |
| 610 | Link<weld::MetricSpinButton&,void> aLk = LINK(this, SvxSwPosSizeTabPage, ModifyHdl); |
| 611 | m_xWidthMF->connect_value_changed( aLk ); |
| 612 | m_xHeightMF->connect_value_changed( aLk ); |
| 613 | m_xHoriByMF->connect_value_changed( aLk ); |
| 614 | m_xVertByMF->connect_value_changed( aLk ); |
| 615 | |
| 616 | Link<weld::Toggleable&,void> aLk2 = LINK(this, SvxSwPosSizeTabPage, AnchorTypeHdl); |
| 617 | m_xToPageRB->connect_toggled( aLk2 ); |
| 618 | m_xToParaRB->connect_toggled( aLk2 ); |
| 619 | m_xToCharRB->connect_toggled( aLk2 ); |
| 620 | m_xAsCharRB->connect_toggled( aLk2 ); |
| 621 | m_xToFrameRB->connect_toggled( aLk2 ); |
| 622 | |
| 623 | m_xHoriLB->connect_changed(LINK(this, SvxSwPosSizeTabPage, PosHdl)); |
| 624 | m_xVertLB->connect_changed(LINK(this, SvxSwPosSizeTabPage, PosHdl)); |
| 625 | |
| 626 | m_xHoriToLB->connect_changed(LINK(this, SvxSwPosSizeTabPage, RelHdl)); |
| 627 | m_xVertToLB->connect_changed(LINK(this, SvxSwPosSizeTabPage, RelHdl)); |
| 628 | |
| 629 | m_xHoriMirrorCB->connect_toggled(LINK(this, SvxSwPosSizeTabPage, MirrorHdl)); |
| 630 | m_xPositionCB->connect_toggled(LINK(this, SvxSwPosSizeTabPage, ProtectHdl)); |
| 631 | } |
| 632 | |
| 633 | SvxSwPosSizeTabPage::~SvxSwPosSizeTabPage() |
| 634 | { |
| 635 | m_xWidthMF.reset(); |
| 636 | m_xHeightMF.reset(); |
| 637 | m_xHoriByMF.reset(); |
| 638 | m_xVertByMF.reset(); |
| 639 | } |
| 640 | |
| 641 | namespace |
| 642 | { |
| 643 | struct FrmMaps |
| 644 | { |
| 645 | FrmMap const *pMap; |
| 646 | size_t nCount; |
| 647 | }; |
| 648 | } |
| 649 | |
| 650 | void SvxSwPosSizeTabPage::setOptimalFrmWidth() |
| 651 | { |
| 652 | static const FrmMaps aMaps[] = { |
| 653 | { aHPageMap, std::size(aHPageMap) }, |
| 654 | { aHPageHtmlMap, std::size(aHPageHtmlMap) }, |
| 655 | { aVPageMap, std::size(aVPageMap) }, |
| 656 | { aVPageHtmlMap, std::size(aVPageHtmlMap) }, |
| 657 | { aHFrameMap, std::size(aHFrameMap) }, |
| 658 | { aHFlyHtmlMap, std::size(aHFlyHtmlMap) }, |
| 659 | { aVFrameMap, std::size(aVFrameMap) }, |
| 660 | { aVFlyHtmlMap, std::size(aVFlyHtmlMap) }, |
| 661 | { aHParaMap, std::size(aHParaMap) }, |
| 662 | { aHParaHtmlMap, std::size(aHParaHtmlMap) }, |
| 663 | { aHParaHtmlAbsMap, std::size(aHParaHtmlAbsMap) }, |
| 664 | { aVParaMap, std::size(aVParaMap) }, |
| 665 | { aVParaHtmlMap, std::size(aVParaHtmlMap) }, |
| 666 | { aHCharMap, std::size(aHCharMap) }, |
| 667 | { aHCharHtmlMap, std::size(aHCharHtmlMap) }, |
| 668 | { aHCharHtmlAbsMap, std::size(aHCharHtmlAbsMap) }, |
| 669 | { aVCharMap, std::size(aVCharMap) }, |
| 670 | { aVCharHtmlMap, std::size(aVCharHtmlMap) }, |
| 671 | { aVCharHtmlAbsMap, std::size(aVCharHtmlAbsMap) }, |
| 672 | { aVAsCharMap, std::size(aVAsCharMap) }, |
| 673 | { aVAsCharHtmlMap, std::size(aVAsCharHtmlMap) } |
| 674 | }; |
| 675 | |
| 676 | std::vector<SvxSwFramePosString::StringId> aFrames; |
| 677 | for (const FrmMaps& aMap : aMaps) |
| 678 | { |
| 679 | for (size_t j = 0; j < aMap.nCount; ++j) |
| 680 | { |
| 681 | aFrames.push_back(aMap.pMap[j].eStrId); |
| 682 | aFrames.push_back(aMap.pMap[j].eMirrorStrId); |
| 683 | } |
| 684 | } |
| 685 | |
| 686 | std::sort(aFrames.begin(), aFrames.end()); |
| 687 | aFrames.erase(std::unique(aFrames.begin(), aFrames.end()), aFrames.end()); |
| 688 | |
| 689 | for (auto const& frame : aFrames) |
| 690 | { |
| 691 | m_xHoriLB->append_text(SvxSwFramePosString::GetString(frame)); |
| 692 | } |
| 693 | |
| 694 | Size aBiggest(m_xHoriLB->get_preferred_size()); |
| 695 | m_xHoriLB->set_size_request(aBiggest.Width(), -1); |
| 696 | m_xVertLB->set_size_request(aBiggest.Width(), -1); |
| 697 | m_xHoriLB->clear(); |
| 698 | } |
| 699 | |
| 700 | namespace |
| 701 | { |
| 702 | struct RelationMaps |
| 703 | { |
| 704 | RelationMap const *pMap; |
| 705 | size_t nCount; |
| 706 | }; |
| 707 | } |
| 708 | |
| 709 | void SvxSwPosSizeTabPage::setOptimalRelWidth() |
| 710 | { |
| 711 | static const RelationMaps aMaps[] = { |
| 712 | { aRelationMap, std::size(aRelationMap) }, |
| 713 | { aAsCharRelationMap, std::size(aAsCharRelationMap) } |
| 714 | }; |
| 715 | |
| 716 | std::vector<SvxSwFramePosString::StringId> aRels; |
| 717 | for (const RelationMaps& aMap : aMaps) |
| 718 | { |
| 719 | for (size_t j = 0; j < aMap.nCount; ++j) |
| 720 | { |
| 721 | aRels.push_back(aMap.pMap[j].eStrId); |
| 722 | aRels.push_back(aMap.pMap[j].eMirrorStrId); |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | std::sort(aRels.begin(), aRels.end()); |
| 727 | aRels.erase(std::unique(aRels.begin(), aRels.end()), aRels.end()); |
| 728 | |
| 729 | for (auto const& elem : aRels) |
| 730 | { |
| 731 | m_xHoriLB->append_text(SvxSwFramePosString::GetString(elem)); |
| 732 | } |
| 733 | |
| 734 | Size aBiggest(m_xHoriLB->get_preferred_size()); |
| 735 | m_xHoriLB->set_size_request(aBiggest.Width(), -1); |
| 736 | m_xVertLB->set_size_request(aBiggest.Width(), -1); |
| 737 | m_xHoriLB->clear(); |
| 738 | } |
| 739 | |
| 740 | std::unique_ptr<SfxTabPage> SvxSwPosSizeTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet) |
| 741 | { |
| 742 | return std::make_unique<SvxSwPosSizeTabPage>(pPage, pController, *rSet); |
| 743 | } |
| 744 | |
| 745 | const WhichRangesContainer & SvxSwPosSizeTabPage::GetRanges() |
| 746 | { |
| 747 | static const WhichRangesContainer ranges(svl::Items< |
| 748 | SID_ATTR_TRANSFORM_POS_X, SID_ATTR_TRANSFORM_POS_Y, |
| 749 | SID_ATTR_TRANSFORM_WIDTH, SID_ATTR_TRANSFORM_SIZE_POINT, |
| 750 | SID_ATTR_TRANSFORM_PROTECT_POS, SID_ATTR_TRANSFORM_INTERN, |
| 751 | SID_ATTR_TRANSFORM_AUTOWIDTH, SID_ATTR_TRANSFORM_VERT_ORIENT, |
| 752 | SID_HTML_MODE, SID_HTML_MODE, |
| 753 | SID_SW_FOLLOW_TEXT_FLOW, SID_SW_FOLLOW_TEXT_FLOW, |
| 754 | SID_ATTR_TRANSFORM_HORI_POSITION, SID_ATTR_TRANSFORM_VERT_POSITION, |
| 755 | SID_ATTR_CHAR_GRABBAG, SID_ATTR_CHAR_GRABBAG |
| 756 | >); |
| 757 | return ranges; |
| 758 | } |
| 759 | |
| 760 | bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) |
| 761 | { |
| 762 | bool bAnchorChanged = false; |
| 763 | RndStdIds nAnchor = GetAnchorType(&bAnchorChanged); |
| 764 | bool bModified = false; |
| 765 | if(bAnchorChanged) |
| 766 | { |
| 767 | rSet->Put(SfxInt16Item(SID_ATTR_TRANSFORM_ANCHOR, static_cast<sal_Int16>(nAnchor))); |
| 768 | bModified = true; |
| 769 | } |
| 770 | if (m_xPositionCB->get_state_changed_from_saved()) |
| 771 | { |
| 772 | if (m_xPositionCB->get_state() == TRISTATE_INDET) |
| 773 | rSet->InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_POS ); |
| 774 | else |
| 775 | rSet->Put( |
| 776 | SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_POS, |
| 777 | m_xPositionCB->get_state() == TRISTATE_TRUE ) ); |
| 778 | bModified = true; |
| 779 | } |
| 780 | |
| 781 | if (m_xSizeCB->get_state_changed_from_saved()) |
| 782 | { |
| 783 | if (m_xSizeCB->get_state() == TRISTATE_INDET) |
| 784 | rSet->InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_SIZE ); |
| 785 | else |
| 786 | rSet->Put( |
| 787 | SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, |
| 788 | m_xSizeCB->get_state() == TRISTATE_TRUE ) ); |
| 789 | bModified = true; |
| 790 | } |
| 791 | |
| 792 | const SfxItemSet& rOldSet = GetItemSet(); |
| 793 | |
| 794 | if(!m_bPositioningDisabled) |
| 795 | { |
| 796 | //on multiple selections the positioning is set via SdrView |
| 797 | if (m_bIsMultiSelection) |
| 798 | { |
| 799 | if (m_xHoriByMF->get_value_changed_from_saved() || m_xVertByMF->get_value_changed_from_saved()) |
| 800 | { |
| 801 | auto nHoriByPos = m_xHoriByMF->denormalize(m_xHoriByMF->get_value(FieldUnit::TWIP)); |
| 802 | auto nVertByPos = m_xVertByMF->denormalize(m_xVertByMF->get_value(FieldUnit::TWIP)); |
| 803 | |
| 804 | // old rectangle with CoreUnit |
| 805 | m_aRect = m_pSdrView->GetAllMarkedRect(); |
| 806 | m_pSdrView->GetSdrPageView()->LogicToPagePos( m_aRect ); |
| 807 | |
| 808 | nHoriByPos += m_aAnchorPos.X(); |
| 809 | nVertByPos += m_aAnchorPos.Y(); |
| 810 | |
| 811 | rSet->Put( SfxInt32Item( SID_ATTR_TRANSFORM_POS_X, nHoriByPos ) ); |
| 812 | rSet->Put( SfxInt32Item( SID_ATTR_TRANSFORM_POS_Y, nVertByPos ) ); |
| 813 | |
| 814 | bModified = true; |
| 815 | } |
| 816 | } |
| 817 | else |
| 818 | { |
| 819 | if ( m_pHMap ) |
| 820 | { |
| 821 | const SfxInt16Item& rHoriOrient = |
| 822 | rOldSet.Get( SID_ATTR_TRANSFORM_HORI_ORIENT ); |
| 823 | const SfxInt16Item& rHoriRelation = |
| 824 | rOldSet.Get( SID_ATTR_TRANSFORM_HORI_RELATION); |
| 825 | const SfxInt32Item& rHoriPosition = |
| 826 | rOldSet.Get( SID_ATTR_TRANSFORM_HORI_POSITION); |
| 827 | |
| 828 | sal_uInt16 nMapPos = GetMapPos(m_pHMap, *m_xHoriLB); |
| 829 | short nAlign = GetAlignment(m_pHMap, nMapPos, *m_xHoriToLB); |
| 830 | short nRel = GetRelation(*m_xHoriToLB); |
| 831 | const auto nHoriByPos = m_xHoriByMF->denormalize(m_xHoriByMF->get_value(FieldUnit::TWIP)); |
| 832 | if ( |
| 833 | nAlign != rHoriOrient.GetValue() || |
| 834 | nRel != rHoriRelation.GetValue() || |
| 835 | (m_xHoriByMF->get_sensitive() && nHoriByPos != rHoriPosition.GetValue()) |
| 836 | ) |
| 837 | { |
| 838 | rSet->Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_ORIENT, nAlign)); |
| 839 | rSet->Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_RELATION, nRel)); |
| 840 | if(m_xHoriByMF->get_sensitive()) |
| 841 | rSet->Put(SfxInt32Item(SID_ATTR_TRANSFORM_HORI_POSITION, nHoriByPos)); |
| 842 | bModified = true; |
| 843 | } |
| 844 | } |
| 845 | if (m_xHoriMirrorCB->get_sensitive() && m_xHoriMirrorCB->get_state_changed_from_saved()) |
| 846 | bModified |= nullptr != rSet->Put(SfxBoolItem(SID_ATTR_TRANSFORM_HORI_MIRROR, m_xHoriMirrorCB->get_active())); |
| 847 | |
| 848 | if ( m_pVMap ) |
| 849 | { |
| 850 | const SfxInt16Item& rVertOrient = |
| 851 | rOldSet.Get( SID_ATTR_TRANSFORM_VERT_ORIENT); |
| 852 | const SfxInt16Item& rVertRelation = |
| 853 | rOldSet.Get( SID_ATTR_TRANSFORM_VERT_RELATION); |
| 854 | const SfxInt32Item& rVertPosition = |
| 855 | rOldSet.Get( SID_ATTR_TRANSFORM_VERT_POSITION); |
| 856 | |
| 857 | sal_uInt16 nMapPos = GetMapPos(m_pVMap, *m_xVertLB); |
| 858 | short nAlign = GetAlignment(m_pVMap, nMapPos, *m_xVertToLB); |
| 859 | short nRel = GetRelation(*m_xVertToLB); |
| 860 | // #i34055# - convert vertical position for |
| 861 | // as-character anchored objects |
| 862 | auto nVertByPos = m_xVertByMF->denormalize(m_xVertByMF->get_value(FieldUnit::TWIP)); |
| 863 | if (GetAnchorType() == RndStdIds::FLY_AS_CHAR) |
| 864 | { |
| 865 | nVertByPos *= -1; |
| 866 | } |
| 867 | if ( nAlign != rVertOrient.GetValue() || |
| 868 | nRel != rVertRelation.GetValue() || |
| 869 | ( m_xVertByMF->get_sensitive() && |
| 870 | nVertByPos != rVertPosition.GetValue() ) ) |
| 871 | { |
| 872 | rSet->Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_ORIENT, nAlign)); |
| 873 | rSet->Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_RELATION, nRel)); |
| 874 | if(m_xVertByMF->get_sensitive()) |
| 875 | rSet->Put(SfxInt32Item(SID_ATTR_TRANSFORM_VERT_POSITION, nVertByPos)); |
| 876 | bModified = true; |
| 877 | } |
| 878 | } |
| 879 | |
| 880 | // #i18732# |
| 881 | if (m_xFollowCB->get_state_changed_from_saved()) |
| 882 | { |
| 883 | //Writer internal type - based on SfxBoolItem |
| 884 | const SfxPoolItem* pItem = GetItem( rOldSet, SID_SW_FOLLOW_TEXT_FLOW); |
| 885 | if(pItem) |
| 886 | { |
| 887 | std::unique_ptr<SfxBoolItem> pFollow(static_cast<SfxBoolItem*>(pItem->Clone())); |
| 888 | pFollow->SetValue(m_xFollowCB->get_active()); |
| 889 | bModified |= nullptr != rSet->Put(std::move(pFollow)); |
| 890 | } |
| 891 | } |
| 892 | } |
| 893 | } |
| 894 | if (m_xWidthMF->get_value_changed_from_saved() || m_xHeightMF->get_value_changed_from_saved()) |
| 895 | { |
| 896 | sal_uInt32 nWidth = static_cast<sal_uInt32>(m_xWidthMF->denormalize(m_xWidthMF->get_value(FieldUnit::TWIP))); |
| 897 | sal_uInt32 nHeight = static_cast<sal_uInt32>(m_xHeightMF->denormalize(m_xHeightMF->get_value(FieldUnit::TWIP))); |
| 898 | rSet->Put( SfxUInt32Item( SID_ATTR_TRANSFORM_WIDTH, nWidth ) ); |
| 899 | rSet->Put( SfxUInt32Item( SID_ATTR_TRANSFORM_HEIGHT, nHeight ) ); |
| 900 | //this item is required by SdrEditView::SetGeoAttrToMarked() |
| 901 | rSet->Put( SfxUInt16Item( SID_ATTR_TRANSFORM_SIZE_POINT, sal_uInt16(RectPoint::LT) ) ); |
| 902 | |
| 903 | bModified = true; |
| 904 | } |
| 905 | |
| 906 | return bModified; |
| 907 | } |
| 908 | |
| 909 | void SvxSwPosSizeTabPage::Reset( const SfxItemSet* rSet) |
| 910 | { |
| 911 | const SfxPoolItem* pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_ANCHOR ); |
| 912 | bool bInvalidateAnchor = false; |
| 913 | RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA; |
| 914 | if(pItem) |
| 915 | { |
| 916 | nAnchorType = static_cast<RndStdIds>(static_cast<const SfxInt16Item*>(pItem)->GetValue()); |
| 917 | switch(nAnchorType) |
| 918 | { |
| 919 | case RndStdIds::FLY_AT_PAGE: m_xToPageRB->set_active(true); break; |
| 920 | case RndStdIds::FLY_AT_PARA: m_xToParaRB->set_active(true); break; |
| 921 | case RndStdIds::FLY_AT_CHAR: m_xToCharRB->set_active(true); break; |
| 922 | case RndStdIds::FLY_AS_CHAR: m_xAsCharRB->set_active(true); break; |
| 923 | case RndStdIds::FLY_AT_FLY: m_xToFrameRB->set_active(true); break; |
| 924 | default : bInvalidateAnchor = true; |
| 925 | } |
| 926 | m_xToPageRB->save_state(); |
| 927 | m_xToParaRB->save_state(); |
| 928 | m_xToCharRB->save_state(); |
| 929 | m_xAsCharRB->save_state(); |
| 930 | m_xToFrameRB->save_state(); |
| 931 | } |
| 932 | if (bInvalidateAnchor) |
| 933 | { |
| 934 | m_xToPageRB->set_sensitive( false ); |
| 935 | m_xToParaRB->set_sensitive( false ); |
| 936 | m_xToCharRB->set_sensitive( false ); |
| 937 | m_xAsCharRB->set_sensitive( false ); |
| 938 | m_xToFrameRB->set_sensitive( false ); |
| 939 | } |
| 940 | |
| 941 | pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_PROTECT_POS ); |
| 942 | if (pItem) |
| 943 | { |
| 944 | bool bProtected = static_cast<const SfxBoolItem*>(pItem)->GetValue(); |
| 945 | m_xPositionCB->set_active(bProtected); |
| 946 | m_xSizeCB->set_sensitive(!bProtected); |
| 947 | } |
| 948 | else |
| 949 | { |
| 950 | m_xPositionCB->set_state(TRISTATE_INDET); |
| 951 | } |
| 952 | |
| 953 | m_xPositionCB->save_state(); |
| 954 | |
| 955 | pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_PROTECT_SIZE ); |
| 956 | |
| 957 | if (pItem) |
| 958 | { |
| 959 | m_xSizeCB->set_active(static_cast<const SfxBoolItem*>(pItem)->GetValue()); |
| 960 | } |
| 961 | else |
| 962 | m_xSizeCB->set_state(TRISTATE_INDET); |
| 963 | m_xSizeCB->save_state(); |
| 964 | |
| 965 | pItem = GetItem( *rSet, SID_HTML_MODE ); |
| 966 | if(pItem) |
| 967 | { |
| 968 | m_bHtmlMode = |
| 969 | (static_cast<const SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON) |
| 970 | != 0; |
| 971 | } |
| 972 | |
| 973 | pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_IN_VERTICAL_TEXT ); |
| 974 | if(pItem && static_cast<const SfxBoolItem*>(pItem)->GetValue()) |
| 975 | { |
| 976 | OUString sHLabel = m_xHoriFT->get_label(); |
| 977 | m_xHoriFT->set_label(m_xVertFT->get_label()); |
| 978 | m_xVertFT->set_label(sHLabel); |
| 979 | m_bIsVerticalFrame = true; |
| 980 | } |
| 981 | pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_IN_RTL_TEXT); |
| 982 | if(pItem) |
| 983 | m_bIsInRightToLeft = static_cast<const SfxBoolItem*>(pItem)->GetValue(); |
| 984 | |
| 985 | pItem = GetItem( *rSet, SID_SW_FOLLOW_TEXT_FLOW); |
| 986 | if(pItem) |
| 987 | { |
| 988 | const bool bFollowTextFlow = |
| 989 | static_cast<const SfxBoolItem*>(pItem)->GetValue(); |
| 990 | m_xFollowCB->set_active(bFollowTextFlow); |
| 991 | } |
| 992 | m_xFollowCB->save_state(); |
| 993 | |
| 994 | const SfxGrabBagItem* pGrabBag = GetItem(*rSet, SID_ATTR_CHAR_GRABBAG); |
| 995 | if (pGrabBag) |
| 996 | { |
| 997 | const std::map<OUString, css::uno::Any>& rMap = pGrabBag->GetGrabBag(); |
| 998 | auto it = rMap.find(u"DoNotMirrorRtlDrawObjs"_ustr); |
| 999 | if (it != rMap.end()) |
| 1000 | { |
| 1001 | it->second >>= m_bDoNotMirrorRtlDrawObjs; |
| 1002 | } |
| 1003 | } |
| 1004 | |
| 1005 | if(m_bHtmlMode) |
| 1006 | { |
| 1007 | m_xHoriMirrorCB->hide(); |
| 1008 | m_xKeepRatioCB->set_sensitive(false); |
| 1009 | // #i18732# - hide checkbox in HTML mode |
| 1010 | m_xFollowCB->hide(); |
| 1011 | } |
| 1012 | else |
| 1013 | { |
| 1014 | // #i18732# correct enable/disable of check box 'Mirror on..' |
| 1015 | m_xHoriMirrorCB->set_sensitive(!m_xAsCharRB->get_active() && !m_bIsMultiSelection); |
| 1016 | |
| 1017 | // #i18732# - enable/disable check box 'Follow text flow'. |
| 1018 | m_xFollowCB->set_sensitive(m_xToParaRB->get_active() || |
| 1019 | m_xToCharRB->get_active()); |
| 1020 | } |
| 1021 | |
| 1022 | pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_WIDTH ); |
| 1023 | sal_Int32 nWidth = std::max( pItem ? ( static_cast<const SfxUInt32Item*>(pItem)->GetValue()) : 0, sal_uInt32(1) ); |
| 1024 | |
| 1025 | m_xWidthMF->set_value(m_xWidthMF->normalize(nWidth), FieldUnit::TWIP); |
| 1026 | m_xWidthMF->save_value(); |
| 1027 | |
| 1028 | pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HEIGHT ); |
| 1029 | sal_Int32 nHeight = std::max( pItem ? ( static_cast<const SfxUInt32Item*>(pItem)->GetValue()) : 0, sal_uInt32(1) ); |
| 1030 | m_xHeightMF->set_value(m_xHeightMF->normalize(nHeight), FieldUnit::TWIP); |
| 1031 | m_xHeightMF->save_value(); |
| 1032 | m_fWidthHeightRatio = double(nWidth) / double(nHeight); |
| 1033 | |
| 1034 | if(m_bPositioningDisabled) |
| 1035 | return; |
| 1036 | |
| 1037 | pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HORI_ORIENT); |
| 1038 | if(pItem) |
| 1039 | { |
| 1040 | short nHoriOrientation = static_cast< const SfxInt16Item*>(pItem)->GetValue(); |
| 1041 | m_nOldH = nHoriOrientation; |
| 1042 | } |
| 1043 | pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_VERT_ORIENT); |
| 1044 | if(pItem) |
| 1045 | { |
| 1046 | short nVertOrientation = static_cast< const SfxInt16Item*>(pItem)->GetValue(); |
| 1047 | m_nOldV = nVertOrientation; |
| 1048 | } |
| 1049 | pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HORI_RELATION); |
| 1050 | if(pItem) |
| 1051 | { |
| 1052 | m_nOldHRel = static_cast< const SfxInt16Item*>(pItem)->GetValue(); |
| 1053 | } |
| 1054 | |
| 1055 | pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_VERT_RELATION); |
| 1056 | if(pItem) |
| 1057 | { |
| 1058 | m_nOldVRel = static_cast< const SfxInt16Item*>(pItem)->GetValue(); |
| 1059 | } |
| 1060 | pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HORI_MIRROR); |
| 1061 | if(pItem) |
| 1062 | m_xHoriMirrorCB->set_active(static_cast<const SfxBoolItem*>(pItem)->GetValue()); |
| 1063 | m_xHoriMirrorCB->save_state(); |
| 1064 | |
| 1065 | sal_Int32 nHoriPos = 0; |
| 1066 | sal_Int32 nVertPos = 0; |
| 1067 | pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HORI_POSITION); |
| 1068 | if(pItem) |
| 1069 | nHoriPos = static_cast<const SfxInt32Item*>(pItem)->GetValue(); |
| 1070 | pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_VERT_POSITION); |
| 1071 | if(pItem) |
| 1072 | nVertPos = static_cast<const SfxInt32Item*>(pItem)->GetValue(); |
| 1073 | |
| 1074 | InitPos(nAnchorType, m_nOldH, m_nOldHRel, m_nOldV, m_nOldVRel, nHoriPos, nVertPos); |
| 1075 | |
| 1076 | m_xVertByMF->save_value(); |
| 1077 | m_xHoriByMF->save_value(); |
| 1078 | // #i18732# |
| 1079 | m_xFollowCB->save_state(); |
| 1080 | |
| 1081 | RangeModifyHdl(m_xWidthMF->get_widget()); // initially set maximum values |
| 1082 | } |
| 1083 | |
| 1084 | DeactivateRC SvxSwPosSizeTabPage::DeactivatePage( SfxItemSet* _pSet ) |
| 1085 | { |
| 1086 | if( _pSet ) |
| 1087 | { |
| 1088 | _pSet->Put(SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_POS, |
| 1089 | m_xPositionCB->get_active())); |
| 1090 | _pSet->Put(SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, |
| 1091 | m_xSizeCB->get_active())); |
| 1092 | FillItemSet( _pSet ); |
| 1093 | } |
| 1094 | return DeactivateRC::LeavePage; |
| 1095 | } |
| 1096 | |
| 1097 | void SvxSwPosSizeTabPage::EnableAnchorTypes(SvxAnchorIds nAnchorEnable) |
| 1098 | { |
| 1099 | if (nAnchorEnable & SvxAnchorIds::Fly) |
| 1100 | m_xToFrameRB->show(); |
| 1101 | if (!(nAnchorEnable & SvxAnchorIds::Page)) |
| 1102 | m_xToPageRB->set_sensitive(false); |
| 1103 | } |
| 1104 | |
| 1105 | RndStdIds SvxSwPosSizeTabPage::GetAnchorType(bool* pbHasChanged) |
| 1106 | { |
| 1107 | RndStdIds nRet = RndStdIds::UNKNOWN; |
| 1108 | weld::RadioButton* pCheckedButton = nullptr; |
| 1109 | if(m_xToParaRB->get_sensitive()) |
| 1110 | { |
| 1111 | if(m_xToPageRB->get_active()) |
| 1112 | { |
| 1113 | nRet = RndStdIds::FLY_AT_PAGE; |
| 1114 | pCheckedButton = m_xToPageRB.get(); |
| 1115 | } |
| 1116 | else if(m_xToParaRB->get_active()) |
| 1117 | { |
| 1118 | nRet = RndStdIds::FLY_AT_PARA; |
| 1119 | pCheckedButton = m_xToParaRB.get(); |
| 1120 | } |
| 1121 | else if(m_xToCharRB->get_active()) |
| 1122 | { |
| 1123 | nRet = RndStdIds::FLY_AT_CHAR; |
| 1124 | pCheckedButton = m_xToCharRB.get(); |
| 1125 | } |
| 1126 | else if(m_xAsCharRB->get_active()) |
| 1127 | { |
| 1128 | nRet = RndStdIds::FLY_AS_CHAR; |
| 1129 | pCheckedButton = m_xAsCharRB.get(); |
| 1130 | } |
| 1131 | else if(m_xToFrameRB->get_active()) |
| 1132 | { |
| 1133 | nRet = RndStdIds::FLY_AT_FLY; |
| 1134 | pCheckedButton = m_xToFrameRB.get(); |
| 1135 | } |
| 1136 | } |
| 1137 | if(pbHasChanged) |
| 1138 | { |
| 1139 | if(pCheckedButton) |
| 1140 | *pbHasChanged = pCheckedButton->get_state_changed_from_saved(); |
| 1141 | else |
| 1142 | *pbHasChanged = false; |
| 1143 | } |
| 1144 | return nRet; |
| 1145 | } |
| 1146 | |
| 1147 | IMPL_LINK_NOARG(SvxSwPosSizeTabPage, RatioHdl_Impl, weld::Toggleable&, void) |
| 1148 | { |
| 1149 | m_xCbxScaleImg->set_from_icon_name(m_xKeepRatioCB->get_active() ? RID_SVXBMP_LOCKED : RID_SVXBMP_UNLOCKED); |
| 1150 | } |
| 1151 | |
| 1152 | IMPL_LINK_NOARG(SvxSwPosSizeTabPage, RangeModifyClickHdl, weld::Toggleable&, void) |
| 1153 | { |
| 1154 | RangeModifyHdl(m_xWidthMF->get_widget()); |
| 1155 | } |
| 1156 | |
| 1157 | IMPL_LINK_NOARG(SvxSwPosSizeTabPage, RangeModifyHdl, weld::Widget&, void) |
| 1158 | { |
| 1159 | if (m_bPositioningDisabled) |
| 1160 | return; |
| 1161 | SvxSwFrameValidation aVal; |
| 1162 | |
| 1163 | aVal.nAnchorType = GetAnchorType(); |
| 1164 | aVal.bAutoHeight = false; |
| 1165 | aVal.bMirror = m_xHoriMirrorCB->get_active(); |
| 1166 | // #i18732# |
| 1167 | aVal.bFollowTextFlow = m_xFollowCB->get_active(); |
| 1168 | |
| 1169 | if ( m_pHMap ) |
| 1170 | { |
| 1171 | // horizontal alignment |
| 1172 | sal_uInt16 nMapPos = GetMapPos(m_pHMap, *m_xHoriToLB); |
| 1173 | sal_uInt16 nAlign = GetAlignment(m_pHMap, nMapPos, *m_xHoriToLB); |
| 1174 | sal_uInt16 nRel = GetRelation(*m_xHoriToLB); |
| 1175 | |
| 1176 | aVal.nHoriOrient = static_cast<short>(nAlign); |
| 1177 | aVal.nHRelOrient = static_cast<short>(nRel); |
| 1178 | } |
| 1179 | else |
| 1180 | aVal.nHoriOrient = HoriOrientation::NONE; |
| 1181 | |
| 1182 | if ( m_pVMap ) |
| 1183 | { |
| 1184 | // vertical alignment |
| 1185 | sal_uInt16 nMapPos = GetMapPos(m_pVMap, *m_xVertLB); |
| 1186 | sal_uInt16 nAlign = GetAlignment(m_pVMap, nMapPos, *m_xVertToLB); |
| 1187 | sal_uInt16 nRel = GetRelation(*m_xVertToLB); |
| 1188 | |
| 1189 | aVal.nVertOrient = static_cast<short>(nAlign); |
| 1190 | aVal.nVRelOrient = static_cast<short>(nRel); |
| 1191 | } |
| 1192 | else |
| 1193 | aVal.nVertOrient = VertOrientation::NONE; |
| 1194 | |
| 1195 | const auto nAtHorzPosVal = m_xHoriByMF->denormalize(m_xHoriByMF->get_value(FieldUnit::TWIP)); |
| 1196 | const auto nAtVertPosVal = m_xVertByMF->denormalize(m_xVertByMF->get_value(FieldUnit::TWIP)); |
| 1197 | |
| 1198 | aVal.nHPos = nAtHorzPosVal; |
| 1199 | aVal.nVPos = nAtVertPosVal; |
| 1200 | |
| 1201 | sal_Int32 nWidth = static_cast<sal_uInt32>(m_xWidthMF->denormalize(m_xWidthMF->get_value(FieldUnit::TWIP))); |
| 1202 | sal_Int32 nHeight = static_cast<sal_uInt32>(m_xHeightMF->denormalize(m_xHeightMF->get_value(FieldUnit::TWIP))); |
| 1203 | aVal.nWidth = nWidth; |
| 1204 | aVal.nHeight = nHeight; |
| 1205 | |
| 1206 | m_aValidateLink.Call(aVal); |
| 1207 | |
| 1208 | // minimum width also for style |
| 1209 | m_xHeightMF->set_min(m_xHeightMF->normalize(aVal.nMinHeight), FieldUnit::TWIP); |
| 1210 | m_xWidthMF->set_min(m_xWidthMF->normalize(aVal.nMinWidth), FieldUnit::TWIP); |
| 1211 | |
| 1212 | sal_Int32 nMaxWidth(aVal.nMaxWidth); |
| 1213 | sal_Int32 nMaxHeight(aVal.nMaxHeight); |
| 1214 | |
| 1215 | sal_Int64 nTmp = m_xHeightMF->normalize(nMaxHeight); |
| 1216 | m_xHeightMF->set_max(nTmp, FieldUnit::TWIP); |
| 1217 | |
| 1218 | nTmp = m_xWidthMF->normalize(nMaxWidth); |
| 1219 | m_xWidthMF->set_max(nTmp, FieldUnit::TWIP); |
| 1220 | |
| 1221 | m_xHoriByMF->set_range(m_xHoriByMF->normalize(aVal.nMinHPos), |
| 1222 | m_xHoriByMF->normalize(aVal.nMaxHPos), FieldUnit::TWIP); |
| 1223 | if ( aVal.nHPos != nAtHorzPosVal ) |
| 1224 | m_xHoriByMF->set_value(m_xHoriByMF->normalize(aVal.nHPos), FieldUnit::TWIP); |
| 1225 | |
| 1226 | m_xVertByMF->set_range(m_xVertByMF->normalize(aVal.nMinVPos), |
| 1227 | m_xVertByMF->normalize(aVal.nMaxVPos), FieldUnit::TWIP); |
| 1228 | if ( aVal.nVPos != nAtVertPosVal ) |
| 1229 | m_xVertByMF->set_value(m_xVertByMF->normalize(aVal.nVPos), FieldUnit::TWIP); |
| 1230 | } |
| 1231 | |
| 1232 | IMPL_LINK_NOARG(SvxSwPosSizeTabPage, AnchorTypeHdl, weld::Toggleable&, void) |
| 1233 | { |
| 1234 | m_xHoriMirrorCB->set_sensitive(!m_xAsCharRB->get_active() && !m_bIsMultiSelection); |
| 1235 | |
| 1236 | // #i18732# - enable check box 'Follow text flow' for anchor |
| 1237 | // type to-paragraph' and to-character |
| 1238 | m_xFollowCB->set_sensitive(m_xToParaRB->get_active() || m_xToCharRB->get_active()); |
| 1239 | |
| 1240 | RndStdIds nId = GetAnchorType(); |
| 1241 | |
| 1242 | InitPos( nId, USHRT_MAX, 0, USHRT_MAX, 0, LONG_MAX, LONG_MAX); |
| 1243 | RangeModifyHdl(m_xWidthMF->get_widget()); |
| 1244 | |
| 1245 | if(m_bHtmlMode) |
| 1246 | { |
| 1247 | PosHdl(*m_xHoriLB); |
| 1248 | PosHdl(*m_xVertLB); |
| 1249 | } |
| 1250 | } |
| 1251 | |
| 1252 | IMPL_LINK_NOARG(SvxSwPosSizeTabPage, MirrorHdl, weld::Toggleable&, void) |
| 1253 | { |
| 1254 | RndStdIds nId = GetAnchorType(); |
| 1255 | InitPos( nId, USHRT_MAX, 0, USHRT_MAX, 0, LONG_MAX, LONG_MAX); |
| 1256 | } |
| 1257 | |
| 1258 | IMPL_LINK( SvxSwPosSizeTabPage, RelHdl, weld::ComboBox&, rLB, void ) |
| 1259 | { |
| 1260 | bool bHori = &rLB == m_xHoriToLB.get(); |
| 1261 | |
| 1262 | UpdateExample(); |
| 1263 | |
| 1264 | if (m_bHtmlMode && RndStdIds::FLY_AT_CHAR == GetAnchorType()) // again special treatment |
| 1265 | { |
| 1266 | if(bHori) |
| 1267 | { |
| 1268 | sal_uInt16 nRel = GetRelation(*m_xHoriToLB); |
| 1269 | if(RelOrientation::PRINT_AREA == nRel && 0 == m_xVertLB->get_active()) |
| 1270 | { |
| 1271 | m_xVertLB->set_active(1); |
| 1272 | } |
| 1273 | else if(RelOrientation::CHAR == nRel && 1 == m_xVertLB->get_active()) |
| 1274 | { |
| 1275 | m_xVertLB->set_active(0); |
| 1276 | } |
| 1277 | } |
| 1278 | } |
| 1279 | RangeModifyHdl(m_xWidthMF->get_widget()); |
| 1280 | } |
| 1281 | |
| 1282 | IMPL_LINK(SvxSwPosSizeTabPage, PosHdl, weld::ComboBox&, rLB, void) |
| 1283 | { |
| 1284 | bool bHori = &rLB == m_xHoriLB.get(); |
| 1285 | weld::ComboBox* pRelLB = bHori ? m_xHoriToLB.get() : m_xVertToLB.get(); |
| 1286 | weld::Label* pRelFT = bHori ? m_xHoriToFT.get() : m_xVertToFT.get(); |
| 1287 | FrmMap const *pMap = bHori ? m_pHMap : m_pVMap; |
| 1288 | |
| 1289 | |
| 1290 | sal_uInt16 nMapPos = GetMapPos(pMap, rLB); |
| 1291 | sal_uInt16 nAlign = GetAlignment(pMap, nMapPos, *pRelLB); |
| 1292 | |
| 1293 | if (bHori) |
| 1294 | { |
| 1295 | bool bEnable = HoriOrientation::NONE == nAlign; |
| 1296 | m_xHoriByMF->set_sensitive( bEnable ); |
| 1297 | m_xHoriByFT->set_sensitive( bEnable ); |
| 1298 | } |
| 1299 | else |
| 1300 | { |
| 1301 | bool bEnable = VertOrientation::NONE == nAlign; |
| 1302 | m_xVertByMF->set_sensitive( bEnable ); |
| 1303 | m_xVertByFT->set_sensitive( bEnable ); |
| 1304 | } |
| 1305 | |
| 1306 | RangeModifyHdl(m_xWidthMF->get_widget()); |
| 1307 | |
| 1308 | short nRel = 0; |
| 1309 | if (rLB.get_active() != -1) |
| 1310 | { |
| 1311 | if (pRelLB->get_active() != -1) |
| 1312 | nRel = weld::fromId<RelationMap*>(pRelLB->get_active_id())->nRelation; |
| 1313 | |
| 1314 | FillRelLB(pMap, nMapPos, nAlign, nRel, *pRelLB, *pRelFT); |
| 1315 | } |
| 1316 | else |
| 1317 | pRelLB->clear(); |
| 1318 | |
| 1319 | UpdateExample(); |
| 1320 | |
| 1321 | // special treatment for HTML-Mode with horz-vert-dependencies |
| 1322 | if (!(m_bHtmlMode && RndStdIds::FLY_AT_CHAR == GetAnchorType())) |
| 1323 | return; |
| 1324 | |
| 1325 | bool bSet = false; |
| 1326 | if(bHori) |
| 1327 | { |
| 1328 | // on the right only below is allowed - from the left only at the top |
| 1329 | // from the left at the character -> below |
| 1330 | if((HoriOrientation::LEFT == nAlign || HoriOrientation::RIGHT == nAlign) && |
| 1331 | 0 == m_xVertLB->get_active()) |
| 1332 | { |
| 1333 | if(RelOrientation::FRAME == nRel) |
| 1334 | m_xVertLB->set_active(1); |
| 1335 | else |
| 1336 | m_xVertLB->set_active(0); |
| 1337 | bSet = true; |
| 1338 | } |
| 1339 | else if(HoriOrientation::LEFT == nAlign && 1 == m_xVertLB->get_active()) |
| 1340 | { |
| 1341 | m_xVertLB->set_active(0); |
| 1342 | bSet = true; |
| 1343 | } |
| 1344 | else if(HoriOrientation::NONE == nAlign && 1 == m_xVertLB->get_active()) |
| 1345 | { |
| 1346 | m_xVertLB->set_active(0); |
| 1347 | bSet = true; |
| 1348 | } |
| 1349 | if(bSet) |
| 1350 | PosHdl(*m_xVertLB); |
| 1351 | } |
| 1352 | else |
| 1353 | { |
| 1354 | if(VertOrientation::TOP == nAlign) |
| 1355 | { |
| 1356 | if(1 == m_xHoriLB->get_active()) |
| 1357 | { |
| 1358 | m_xHoriLB->set_active(0); |
| 1359 | bSet = true; |
| 1360 | } |
| 1361 | m_xHoriToLB->set_active(1); |
| 1362 | } |
| 1363 | else if(VertOrientation::CHAR_BOTTOM == nAlign) |
| 1364 | { |
| 1365 | if(2 == m_xHoriLB->get_active()) |
| 1366 | { |
| 1367 | m_xHoriLB->set_active(0); |
| 1368 | bSet = true; |
| 1369 | } |
| 1370 | m_xHoriToLB->set_active(0) ; |
| 1371 | } |
| 1372 | if(bSet) |
| 1373 | PosHdl(*m_xHoriLB); |
| 1374 | } |
| 1375 | } |
| 1376 | |
| 1377 | IMPL_LINK( SvxSwPosSizeTabPage, ModifyHdl, weld::MetricSpinButton&, rEdit, void ) |
| 1378 | { |
| 1379 | auto nWidth = m_xWidthMF->denormalize(m_xWidthMF->get_value(FieldUnit::TWIP)); |
| 1380 | auto nHeight = m_xHeightMF->denormalize(m_xHeightMF->get_value(FieldUnit::TWIP)); |
| 1381 | if (m_xKeepRatioCB->get_active()) |
| 1382 | { |
| 1383 | if ( &rEdit == m_xWidthMF.get() ) |
| 1384 | { |
| 1385 | nHeight = int(static_cast<double>(nWidth) / m_fWidthHeightRatio); |
| 1386 | m_xHeightMF->set_value(m_xHeightMF->normalize(nHeight), FieldUnit::TWIP); |
| 1387 | } |
| 1388 | else if(&rEdit == m_xHeightMF.get()) |
| 1389 | { |
| 1390 | nWidth = int(static_cast<double>(nHeight) * m_fWidthHeightRatio); |
| 1391 | m_xWidthMF->set_value(m_xWidthMF->normalize(nWidth), FieldUnit::TWIP); |
| 1392 | } |
| 1393 | } |
| 1394 | m_fWidthHeightRatio = nHeight ? double(nWidth) / double(nHeight) : 1.0; |
| 1395 | UpdateExample(); |
| 1396 | } |
| 1397 | |
| 1398 | IMPL_LINK_NOARG(SvxSwPosSizeTabPage, ProtectHdl, weld::Toggleable&, void) |
| 1399 | { |
| 1400 | if (m_xSizeCB->get_sensitive()) |
| 1401 | { |
| 1402 | m_nProtectSizeState = m_xSizeCB->get_state(); |
| 1403 | } |
| 1404 | |
| 1405 | m_xSizeCB->set_state(m_xPositionCB->get_state() == TRISTATE_TRUE ? TRISTATE_TRUE : m_nProtectSizeState); |
| 1406 | m_xSizeCB->set_sensitive(m_xPositionCB->get_sensitive() && !m_xPositionCB->get_active()); |
| 1407 | } |
| 1408 | |
| 1409 | short SvxSwPosSizeTabPage::GetRelation(const weld::ComboBox& rRelationLB) |
| 1410 | { |
| 1411 | short nRel = 0; |
| 1412 | int nPos = rRelationLB.get_active(); |
| 1413 | if (nPos != -1) |
| 1414 | { |
| 1415 | RelationMap *pEntry = weld::fromId<RelationMap*>(rRelationLB.get_id(nPos)); |
| 1416 | nRel = pEntry->nRelation; |
| 1417 | } |
| 1418 | |
| 1419 | return nRel; |
| 1420 | } |
| 1421 | |
| 1422 | short SvxSwPosSizeTabPage::GetAlignment(FrmMap const *pMap, sal_uInt16 nMapPos, const weld::ComboBox& rRelationLB) |
| 1423 | { |
| 1424 | short nAlign = 0; |
| 1425 | |
| 1426 | // #i22341# - special handling also for map <aVCharMap>, |
| 1427 | // because it contains ambiguous items for alignment |
| 1428 | if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap || |
| 1429 | pMap == aVCharMap ) |
| 1430 | { |
| 1431 | if (rRelationLB.get_active() != -1) |
| 1432 | { |
| 1433 | LB nRel = weld::fromId<RelationMap*>(rRelationLB.get_active_id())->nLBRelation; |
| 1434 | std::size_t nMapCount = ::lcl_GetFrmMapCount(pMap); |
| 1435 | SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId; |
| 1436 | |
| 1437 | for (std::size_t i = 0; i < nMapCount; i++) |
| 1438 | { |
| 1439 | if (pMap[i].eStrId == eStrId) |
| 1440 | { |
| 1441 | LB nLBRelations = pMap[i].nLBRelations; |
| 1442 | if (nLBRelations & nRel) |
| 1443 | { |
| 1444 | nAlign = pMap[i].nAlign; |
| 1445 | break; |
| 1446 | } |
| 1447 | } |
| 1448 | } |
| 1449 | } |
| 1450 | } |
| 1451 | else if (pMap) |
| 1452 | nAlign = pMap[nMapPos].nAlign; |
| 1453 | |
| 1454 | return nAlign; |
| 1455 | } |
| 1456 | |
| 1457 | sal_uInt16 SvxSwPosSizeTabPage::GetMapPos(FrmMap const *pMap, const weld::ComboBox& rAlignLB) |
| 1458 | { |
| 1459 | sal_uInt16 nMapPos = 0; |
| 1460 | int nLBSelPos = rAlignLB.get_active(); |
| 1461 | |
| 1462 | if (nLBSelPos != -1) |
| 1463 | { |
| 1464 | if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap) |
| 1465 | { |
| 1466 | std::size_t nMapCount = ::lcl_GetFrmMapCount(pMap); |
| 1467 | OUString sSelEntry(rAlignLB.get_active_text()); |
| 1468 | |
| 1469 | for (std::size_t i = 0; i < nMapCount; i++) |
| 1470 | { |
| 1471 | SvxSwFramePosString::StringId eResId = pMap[i].eStrId; |
| 1472 | |
| 1473 | OUString sEntry = SvxSwFramePosString::GetString(eResId); |
| 1474 | |
| 1475 | if (sEntry == sSelEntry) |
| 1476 | { |
| 1477 | nMapPos = sal::static_int_cast< sal_uInt16 >(i); |
| 1478 | break; |
| 1479 | } |
| 1480 | } |
| 1481 | } |
| 1482 | else |
| 1483 | nMapPos = nLBSelPos; |
| 1484 | } |
| 1485 | |
| 1486 | return nMapPos; |
| 1487 | } |
| 1488 | |
| 1489 | void SvxSwPosSizeTabPage::InitPos(RndStdIds nAnchor, |
| 1490 | sal_uInt16 nH, |
| 1491 | sal_uInt16 nHRel, |
| 1492 | sal_uInt16 nV, |
| 1493 | sal_uInt16 nVRel, |
| 1494 | tools::Long nX, |
| 1495 | tools::Long nY) |
| 1496 | { |
| 1497 | int nPos = m_xVertLB->get_active(); |
| 1498 | if (nPos != -1 && m_pVMap) |
| 1499 | { |
| 1500 | m_nOldV = m_pVMap[nPos].nAlign; |
| 1501 | nPos = m_xVertToLB->get_active(); |
| 1502 | if (nPos != -1) |
| 1503 | m_nOldVRel = weld::fromId<RelationMap*>(m_xVertToLB->get_id(nPos))->nRelation; |
| 1504 | } |
| 1505 | |
| 1506 | nPos = m_xHoriLB->get_active(); |
| 1507 | if (nPos != -1 && m_pHMap) |
| 1508 | { |
| 1509 | m_nOldH = m_pHMap[nPos].nAlign; |
| 1510 | |
| 1511 | nPos = m_xHoriToLB->get_active(); |
| 1512 | if (nPos != -1) |
| 1513 | m_nOldHRel = weld::fromId<RelationMap*>(m_xHoriToLB->get_id(nPos))->nRelation; |
| 1514 | } |
| 1515 | |
| 1516 | bool bEnable = true; |
| 1517 | if( m_bIsMultiSelection ) |
| 1518 | { |
| 1519 | m_pVMap = aVMultiSelectionMap; |
| 1520 | m_pHMap = aHMultiSelectionMap; |
| 1521 | } |
| 1522 | else if (nAnchor == RndStdIds::FLY_AT_PAGE) |
| 1523 | { |
| 1524 | m_pVMap = m_bHtmlMode ? aVPageHtmlMap : aVPageMap; |
| 1525 | m_pHMap = m_bHtmlMode ? aHPageHtmlMap : aHPageMap; |
| 1526 | } |
| 1527 | else if (nAnchor == RndStdIds::FLY_AT_FLY) |
| 1528 | { |
| 1529 | // #i18732# - own vertical alignment map for to frame |
| 1530 | // anchored objects. |
| 1531 | m_pVMap = m_bHtmlMode ? aVFlyHtmlMap : aVFrameMap; |
| 1532 | m_pHMap = m_bHtmlMode ? aHFlyHtmlMap : aHFrameMap; |
| 1533 | } |
| 1534 | else if (nAnchor == RndStdIds::FLY_AT_PARA) |
| 1535 | { |
| 1536 | if(m_bHtmlMode) |
| 1537 | { |
| 1538 | m_pVMap = aVParaHtmlMap; |
| 1539 | m_pHMap = aHParaHtmlAbsMap; |
| 1540 | } |
| 1541 | else |
| 1542 | { |
| 1543 | m_pVMap = aVParaMap; |
| 1544 | m_pHMap = aHParaMap; |
| 1545 | } |
| 1546 | } |
| 1547 | else if (nAnchor == RndStdIds::FLY_AT_CHAR) |
| 1548 | { |
| 1549 | if(m_bHtmlMode) |
| 1550 | { |
| 1551 | m_pVMap = aVCharHtmlAbsMap; |
| 1552 | m_pHMap = aHCharHtmlAbsMap; |
| 1553 | } |
| 1554 | else |
| 1555 | { |
| 1556 | m_pVMap = aVCharMap; |
| 1557 | m_pHMap = aHCharMap; |
| 1558 | } |
| 1559 | } |
| 1560 | else if (nAnchor == RndStdIds::FLY_AS_CHAR) |
| 1561 | { |
| 1562 | m_pVMap = m_bHtmlMode ? aVAsCharHtmlMap : aVAsCharMap; |
| 1563 | m_pHMap = nullptr; |
| 1564 | bEnable = false; |
| 1565 | } |
| 1566 | m_xHoriLB->set_sensitive(bEnable); |
| 1567 | m_xHoriFT->set_sensitive(bEnable); |
| 1568 | |
| 1569 | // select current Pos |
| 1570 | // horizontal |
| 1571 | if ( nH == USHRT_MAX ) |
| 1572 | { |
| 1573 | nH = m_nOldH; |
| 1574 | nHRel = m_nOldHRel; |
| 1575 | } |
| 1576 | // #i22341# - pass <nHRel> as 3rd parameter to method <FillPosLB> |
| 1577 | sal_uInt16 nMapPos = FillPosLB(m_pHMap, nH, nHRel, *m_xHoriLB); |
| 1578 | FillRelLB(m_pHMap, nMapPos, nH, nHRel, *m_xHoriToLB, *m_xHoriToFT); |
| 1579 | |
| 1580 | // vertical |
| 1581 | if ( nV == USHRT_MAX ) |
| 1582 | { |
| 1583 | nV = m_nOldV; |
| 1584 | nVRel = m_nOldVRel; |
| 1585 | } |
| 1586 | // #i22341# - pass <nVRel> as 3rd parameter to method <FillPosLB> |
| 1587 | nMapPos = FillPosLB(m_pVMap, nV, nVRel, *m_xVertLB); |
| 1588 | FillRelLB(m_pVMap, nMapPos, nV, nVRel, *m_xVertToLB, *m_xVertToFT); |
| 1589 | |
| 1590 | // Edits init |
| 1591 | bEnable = nH == HoriOrientation::NONE && nAnchor != RndStdIds::FLY_AS_CHAR; //#61359# why not in formats&& !bFormat; |
| 1592 | if (!bEnable) |
| 1593 | { |
| 1594 | m_xHoriByMF->set_value(0, FieldUnit::TWIP); |
| 1595 | } |
| 1596 | else if(m_bIsMultiSelection) |
| 1597 | { |
| 1598 | m_xHoriByMF->set_value(m_xHoriByMF->normalize(m_aRect.Left()), FieldUnit::TWIP); |
| 1599 | } |
| 1600 | else |
| 1601 | { |
| 1602 | if (nX != LONG_MAX) |
| 1603 | m_xHoriByMF->set_value(m_xHoriByMF->normalize(nX), FieldUnit::TWIP); |
| 1604 | } |
| 1605 | m_xHoriByFT->set_sensitive(bEnable); |
| 1606 | m_xHoriByMF->set_sensitive(bEnable); |
| 1607 | |
| 1608 | bEnable = nV == VertOrientation::NONE; |
| 1609 | if ( !bEnable ) |
| 1610 | { |
| 1611 | m_xVertByMF->set_value( 0, FieldUnit::TWIP ); |
| 1612 | } |
| 1613 | else if(m_bIsMultiSelection) |
| 1614 | { |
| 1615 | m_xVertByMF->set_value(m_xVertByMF->normalize(m_aRect.Top()), FieldUnit::TWIP); |
| 1616 | } |
| 1617 | else |
| 1618 | { |
| 1619 | if (nAnchor == RndStdIds::FLY_AS_CHAR) |
| 1620 | { |
| 1621 | if ( nY == LONG_MAX ) |
| 1622 | nY = 0; |
| 1623 | else |
| 1624 | nY *= -1; |
| 1625 | } |
| 1626 | if ( nY != LONG_MAX ) |
| 1627 | m_xVertByMF->set_value( m_xVertByMF->normalize(nY), FieldUnit::TWIP ); |
| 1628 | } |
| 1629 | m_xVertByFT->set_sensitive( bEnable ); |
| 1630 | m_xVertByMF->set_sensitive( bEnable ); |
| 1631 | UpdateExample(); |
| 1632 | } |
| 1633 | |
| 1634 | void SvxSwPosSizeTabPage::UpdateExample() |
| 1635 | { |
| 1636 | int nPos = m_xHoriLB->get_active(); |
| 1637 | if (m_pHMap && nPos != -1) |
| 1638 | { |
| 1639 | sal_uInt16 nMapPos = GetMapPos(m_pHMap, *m_xHoriLB); |
| 1640 | short nAlign = GetAlignment(m_pHMap, nMapPos, *m_xHoriToLB); |
| 1641 | short nRel = GetRelation(*m_xHoriToLB); |
| 1642 | |
| 1643 | m_aExampleWN.SetHAlign(nAlign); |
| 1644 | m_aExampleWN.SetHoriRel(nRel); |
| 1645 | } |
| 1646 | |
| 1647 | nPos = m_xVertLB->get_active(); |
| 1648 | if (m_pVMap && nPos != -1) |
| 1649 | { |
| 1650 | sal_uInt16 nMapPos = GetMapPos(m_pVMap, *m_xVertLB); |
| 1651 | sal_uInt16 nAlign = GetAlignment(m_pVMap, nMapPos, *m_xVertToLB); |
| 1652 | sal_uInt16 nRel = GetRelation(*m_xVertToLB); |
| 1653 | |
| 1654 | m_aExampleWN.SetVAlign(nAlign); |
| 1655 | m_aExampleWN.SetVertRel(nRel); |
| 1656 | } |
| 1657 | |
| 1658 | // Size |
| 1659 | auto nXPos = m_xHoriByMF->denormalize(m_xHoriByMF->get_value(FieldUnit::TWIP)); |
| 1660 | auto nYPos = m_xVertByMF->denormalize(m_xVertByMF->get_value(FieldUnit::TWIP)); |
| 1661 | m_aExampleWN.SetRelPos(Point(nXPos, nYPos)); |
| 1662 | |
| 1663 | m_aExampleWN.SetAnchor( GetAnchorType() ); |
| 1664 | m_aExampleWN.Invalidate(); |
| 1665 | } |
| 1666 | |
| 1667 | void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_uInt16 nAlign, |
| 1668 | sal_uInt16 nRel, weld::ComboBox& rLB, weld::Label& rFT) |
| 1669 | { |
| 1670 | OUString sSelEntry; |
| 1671 | LB nLBRelations = LB::NONE; |
| 1672 | std::size_t nMapCount = ::lcl_GetFrmMapCount(pMap); |
| 1673 | |
| 1674 | rLB.clear(); |
| 1675 | |
| 1676 | if (nMapPos < nMapCount) |
| 1677 | { |
| 1678 | if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap) |
| 1679 | { |
| 1680 | OUString sOldEntry(rLB.get_active_text()); |
| 1681 | SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId; |
| 1682 | |
| 1683 | for (std::size_t _nMapPos = 0; _nMapPos < nMapCount; _nMapPos++) |
| 1684 | { |
| 1685 | if (pMap[_nMapPos].eStrId == eStrId) |
| 1686 | { |
| 1687 | nLBRelations = pMap[_nMapPos].nLBRelations; |
| 1688 | for (size_t nRelPos = 0; nRelPos < std::size(aAsCharRelationMap); nRelPos++) |
| 1689 | { |
| 1690 | if (nLBRelations & aAsCharRelationMap[nRelPos].nLBRelation) |
| 1691 | { |
| 1692 | SvxSwFramePosString::StringId sStrId1 = aAsCharRelationMap[nRelPos].eStrId; |
| 1693 | |
| 1694 | sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, m_bIsVerticalFrame, m_bIsInRightToLeft, m_bDoNotMirrorRtlDrawObjs); |
| 1695 | OUString sEntry = SvxSwFramePosString::GetString(sStrId1); |
| 1696 | rLB.append(weld::toId(&aAsCharRelationMap[nRelPos]), sEntry); |
| 1697 | if (pMap[_nMapPos].nAlign == nAlign) |
| 1698 | sSelEntry = sEntry; |
| 1699 | break; |
| 1700 | } |
| 1701 | } |
| 1702 | } |
| 1703 | } |
| 1704 | if (!sSelEntry.isEmpty()) |
| 1705 | rLB.set_active_text(sSelEntry); |
| 1706 | else |
| 1707 | { |
| 1708 | rLB.set_active_text(sOldEntry); |
| 1709 | if (rLB.get_active() == -1) |
| 1710 | { |
| 1711 | for (int i = 0; i < rLB.get_count(); i++) |
| 1712 | { |
| 1713 | RelationMap *pEntry = weld::fromId<RelationMap*>(rLB.get_id(i)); |
| 1714 | if (pEntry->nLBRelation == LB::RelChar) // Default |
| 1715 | { |
| 1716 | rLB.set_active(i); |
| 1717 | break; |
| 1718 | } |
| 1719 | } |
| 1720 | } |
| 1721 | } |
| 1722 | } |
| 1723 | else |
| 1724 | { |
| 1725 | // #i22341# - special handling for map <aVCharMap>, |
| 1726 | // because its ambiguous in its <eStrId>/<eMirrorStrId>. |
| 1727 | if ( pMap == aVCharMap ) |
| 1728 | { |
| 1729 | nLBRelations = ::lcl_GetLBRelationsForStrID( pMap, |
| 1730 | ( m_xHoriMirrorCB->get_active() |
| 1731 | ? pMap[nMapPos].eMirrorStrId |
| 1732 | : pMap[nMapPos].eStrId ), |
| 1733 | m_xHoriMirrorCB->get_active() ); |
| 1734 | } |
| 1735 | else |
| 1736 | { |
| 1737 | nLBRelations = pMap[nMapPos].nLBRelations; |
| 1738 | } |
| 1739 | |
| 1740 | for (std::underlying_type_t<LB> nBit = 1; nBit < o3tl::to_underlying(LB::LAST) ; nBit <<= 1) |
| 1741 | { |
| 1742 | if (nLBRelations & static_cast<LB>(nBit)) |
| 1743 | { |
| 1744 | for (size_t nRelPos = 0; nRelPos < std::size(aRelationMap); nRelPos++) |
| 1745 | { |
| 1746 | if (aRelationMap[nRelPos].nLBRelation == static_cast<LB>(nBit)) |
| 1747 | { |
| 1748 | SvxSwFramePosString::StringId sStrId1 = m_xHoriMirrorCB->get_active() ? aRelationMap[nRelPos].eMirrorStrId : aRelationMap[nRelPos].eStrId; |
| 1749 | sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, m_bIsVerticalFrame, m_bIsInRightToLeft, m_bDoNotMirrorRtlDrawObjs); |
| 1750 | OUString sEntry = SvxSwFramePosString::GetString(sStrId1); |
| 1751 | rLB.append(weld::toId(&aRelationMap[nRelPos]), sEntry); |
| 1752 | if (sSelEntry.isEmpty() && aRelationMap[nRelPos].nRelation == nRel) |
| 1753 | sSelEntry = sEntry; |
| 1754 | } |
| 1755 | } |
| 1756 | } |
| 1757 | } |
| 1758 | if (!sSelEntry.isEmpty()) |
| 1759 | rLB.set_active_text(sSelEntry); |
| 1760 | else |
| 1761 | { |
| 1762 | // Probably anchor change. So look for a similar relation. |
| 1763 | switch (nRel) |
| 1764 | { |
| 1765 | case RelOrientation::FRAME: nRel = RelOrientation::PAGE_FRAME; break; |
| 1766 | case RelOrientation::PRINT_AREA: nRel = RelOrientation::PAGE_PRINT_AREA; break; |
| 1767 | case RelOrientation::PAGE_LEFT: nRel = RelOrientation::FRAME_LEFT; break; |
| 1768 | case RelOrientation::PAGE_RIGHT: nRel = RelOrientation::FRAME_RIGHT; break; |
| 1769 | case RelOrientation::FRAME_LEFT: nRel = RelOrientation::PAGE_LEFT; break; |
| 1770 | case RelOrientation::FRAME_RIGHT: nRel = RelOrientation::PAGE_RIGHT; break; |
| 1771 | case RelOrientation::PAGE_FRAME: nRel = RelOrientation::FRAME; break; |
| 1772 | case RelOrientation::PAGE_PRINT_AREA: nRel = RelOrientation::PRINT_AREA; break; |
| 1773 | |
| 1774 | default: |
| 1775 | if (rLB.get_count()) |
| 1776 | { |
| 1777 | RelationMap *pEntry = weld::fromId<RelationMap*>(rLB.get_id(rLB.get_count() - 1)); |
| 1778 | nRel = pEntry->nRelation; |
| 1779 | } |
| 1780 | break; |
| 1781 | } |
| 1782 | |
| 1783 | for (int i = 0; i < rLB.get_count(); ++i) |
| 1784 | { |
| 1785 | RelationMap *pEntry = weld::fromId<RelationMap*>(rLB.get_id(i)); |
| 1786 | if (pEntry->nRelation == nRel) |
| 1787 | { |
| 1788 | rLB.set_active(i); |
| 1789 | break; |
| 1790 | } |
| 1791 | } |
| 1792 | |
| 1793 | if (rLB.get_active() == -1) |
| 1794 | rLB.set_active(0); |
| 1795 | } |
| 1796 | } |
| 1797 | } |
| 1798 | |
| 1799 | rLB.set_sensitive(rLB.get_count() != 0); |
| 1800 | rFT.set_sensitive(rLB.get_count() != 0); |
| 1801 | |
| 1802 | RelHdl(rLB); |
| 1803 | } |
| 1804 | |
| 1805 | sal_uInt16 SvxSwPosSizeTabPage::FillPosLB(FrmMap const *_pMap, |
| 1806 | sal_uInt16 _nAlign, |
| 1807 | const sal_uInt16 _nRel, |
| 1808 | weld::ComboBox& _rLB) |
| 1809 | { |
| 1810 | OUString sSelEntry, sOldEntry; |
| 1811 | sOldEntry = _rLB.get_active_text(); |
| 1812 | |
| 1813 | _rLB.clear(); |
| 1814 | |
| 1815 | // #i22341# - determine all possible listbox relations for |
| 1816 | // given relation for map <aVCharMap> |
| 1817 | const LB nLBRelations = (_pMap != aVCharMap) |
| 1818 | ? LB::NONE |
| 1819 | : ::lcl_GetLBRelationsForRelations( _nRel ); |
| 1820 | |
| 1821 | // fill listbox |
| 1822 | std::size_t nCount = ::lcl_GetFrmMapCount(_pMap); |
| 1823 | for (std::size_t i = 0; _pMap && i < nCount; ++i) |
| 1824 | { |
| 1825 | SvxSwFramePosString::StringId eStrId = m_xHoriMirrorCB->get_active() ? _pMap[i].eMirrorStrId : _pMap[i].eStrId; |
| 1826 | eStrId = lcl_ChangeResIdToVerticalOrRTL(eStrId, m_bIsVerticalFrame, m_bIsInRightToLeft, m_bDoNotMirrorRtlDrawObjs); |
| 1827 | OUString sEntry(SvxSwFramePosString::GetString(eStrId)); |
| 1828 | if (_rLB.find_text(sEntry) == -1) |
| 1829 | { |
| 1830 | // don't insert duplicate entries at character wrapped borders |
| 1831 | _rLB.append_text(sEntry); |
| 1832 | } |
| 1833 | // #i22341# - add condition to handle map <aVCharMap> |
| 1834 | // that is ambiguous in the alignment. |
| 1835 | if ( _pMap[i].nAlign == _nAlign && |
| 1836 | ( _pMap != aVCharMap || _pMap[i].nLBRelations & nLBRelations ) ) |
| 1837 | { |
| 1838 | sSelEntry = sEntry; |
| 1839 | } |
| 1840 | } |
| 1841 | |
| 1842 | _rLB.set_active_text(sSelEntry); |
| 1843 | if (_rLB.get_active() == -1) |
| 1844 | _rLB.set_active_text(sOldEntry); |
| 1845 | |
| 1846 | if (_rLB.get_active() == -1) |
| 1847 | _rLB.set_active(0); |
| 1848 | |
| 1849 | PosHdl(_rLB); |
| 1850 | |
| 1851 | return GetMapPos(_pMap, _rLB); |
| 1852 | } |
| 1853 | |
| 1854 | void SvxSwPosSizeTabPage::SetView( const SdrView* pSdrView ) |
| 1855 | { |
| 1856 | m_pSdrView = pSdrView; |
| 1857 | if(!m_pSdrView) |
| 1858 | { |
| 1859 | OSL_FAIL("No SdrView* set"); |
| 1860 | return; |
| 1861 | } |
| 1862 | |
| 1863 | // setting of the rectangle and the working area |
| 1864 | m_aRect = m_pSdrView->GetAllMarkedRect(); |
| 1865 | m_pSdrView->GetSdrPageView()->LogicToPagePos( m_aRect ); |
| 1866 | |
| 1867 | // get WorkArea |
| 1868 | m_aWorkArea = m_pSdrView->GetWorkArea(); |
| 1869 | |
| 1870 | // consider anchor position (for Writer) |
| 1871 | const SdrMarkList& rMarkList = m_pSdrView->GetMarkedObjectList(); |
| 1872 | if( rMarkList.GetMarkCount() > 0 ) |
| 1873 | { |
| 1874 | const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); |
| 1875 | m_aAnchorPos = pObj->GetAnchorPos(); |
| 1876 | |
| 1877 | if( m_aAnchorPos != Point(0,0) ) // -> Writer |
| 1878 | { |
| 1879 | for( size_t i = 1; i < rMarkList.GetMarkCount(); ++i ) |
| 1880 | { |
| 1881 | pObj = rMarkList.GetMark( i )->GetMarkedSdrObj(); |
| 1882 | if( m_aAnchorPos != pObj->GetAnchorPos() ) |
| 1883 | { |
| 1884 | // different anchor positions -> disable positioning |
| 1885 | m_xPosFrame->set_sensitive(false); |
| 1886 | m_bPositioningDisabled = true; |
| 1887 | return; |
| 1888 | } |
| 1889 | } |
| 1890 | } |
| 1891 | Point aPt = m_aAnchorPos * -1; |
| 1892 | Point aPt2 = aPt; |
| 1893 | |
| 1894 | aPt += m_aWorkArea.TopLeft(); |
| 1895 | m_aWorkArea.SetPos( aPt ); |
| 1896 | |
| 1897 | aPt2 += m_aRect.TopLeft(); |
| 1898 | m_aRect.SetPos( aPt2 ); |
| 1899 | } |
| 1900 | |
| 1901 | // this should happen via SID_ATTR_TRANSFORM_AUTOSIZE |
| 1902 | if( rMarkList.GetMarkCount() != 1 ) |
| 1903 | m_bIsMultiSelection = true; |
| 1904 | #if OSL_DEBUG_LEVEL > 1 |
| 1905 | else |
| 1906 | { |
| 1907 | const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); |
| 1908 | SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier(); |
| 1909 | if( ( pObj->GetObjInventor() == SdrInventor::Default ) && |
| 1910 | ( eKind==SdrObjKind::Text || eKind==SdrObjKind::TitleText || eKind==SdrObjKind::OutlineText) && |
| 1911 | pObj->HasText() ) |
| 1912 | { |
| 1913 | OSL_FAIL("AutoWidth/AutoHeight should be enabled"); |
| 1914 | } |
| 1915 | } |
| 1916 | #endif |
| 1917 | } |
| 1918 | |
| 1919 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |