LCOV - code coverage report
Current view: top level - sw/source/ui/frmdlg - frmpage.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 1531 0.0 %
Date: 2014-11-03 Functions: 0 92 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 <com/sun/star/embed/Aspects.hpp>
      21             : #include <com/sun/star/embed/EmbedMisc.hpp>
      22             : 
      23             : #include <cmdid.h>
      24             : #include <helpid.h>
      25             : #include <hintids.hxx>
      26             : #include <vcl/msgbox.hxx>
      27             : #include <vcl/mnemonic.hxx>
      28             : #include <svl/urihelper.hxx>
      29             : #include <svl/stritem.hxx>
      30             : #include <sfx2/htmlmode.hxx>
      31             : #include <editeng/sizeitem.hxx>
      32             : #include <editeng/opaqitem.hxx>
      33             : #include <editeng/protitem.hxx>
      34             : #include <editeng/prntitem.hxx>
      35             : #include <editeng/brushitem.hxx>
      36             : #include <editeng/ulspitem.hxx>
      37             : #include <editeng/frmdiritem.hxx>
      38             : #include <svx/swframevalidation.hxx>
      39             : #include <comphelper/classids.hxx>
      40             : 
      41             : #include <sfx2/viewfrm.hxx>
      42             : #include <fmturl.hxx>
      43             : #include <fmteiro.hxx>
      44             : #include <fmtcnct.hxx>
      45             : #include <view.hxx>
      46             : #include <wrtsh.hxx>
      47             : #include <swmodule.hxx>
      48             : #include <uitool.hxx>
      49             : #include <docsh.hxx>
      50             : #include <viewopt.hxx>
      51             : #include <frmatr.hxx>
      52             : #include <frmdlg.hxx>
      53             : #include <frmmgr.hxx>
      54             : #include <frmpage.hxx>
      55             : #include <wrap.hxx>
      56             : #include <colmgr.hxx>
      57             : #include <grfatr.hxx>
      58             : #include <uiitems.hxx>
      59             : #include <fmtfollowtextflow.hxx>
      60             : #include <editeng/adjustitem.hxx>
      61             : #include <svx/sdtaitm.hxx>
      62             : #include <sal/macros.h>
      63             : 
      64             : #include <frmui.hrc>
      65             : #include <sfx2/filedlghelper.hxx>
      66             : #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
      67             : #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
      68             : #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
      69             : #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
      70             : #include <vcl/graphicfilter.hxx>
      71             : #include <boost/scoped_ptr.hpp>
      72             : 
      73             : using namespace ::com::sun::star;
      74             : using namespace ::sfx2;
      75             : 
      76             : #define SwFPos SvxSwFramePosString
      77             : 
      78             : struct FrmMap
      79             : {
      80             :     SvxSwFramePosString::StringId eStrId;
      81             :     SvxSwFramePosString::StringId eMirrorStrId;
      82             :     sal_Int16  nAlign;
      83             :     sal_uLong  nLBRelations;
      84             : };
      85             : 
      86             : struct RelationMap
      87             : {
      88             :     SvxSwFramePosString::StringId eStrId;
      89             :     SvxSwFramePosString::StringId eMirrorStrId;
      90             :     sal_uLong  nLBRelation;
      91             :     sal_Int16  nRelation;
      92             : };
      93             : 
      94             : struct StringIdPair_Impl
      95             : {
      96             :     SvxSwFramePosString::StringId eHori;
      97             :     SvxSwFramePosString::StringId eVert;
      98             : };
      99             : 
     100             : #define MAX_PERCENT_WIDTH   254L
     101             : #define MAX_PERCENT_HEIGHT  254L
     102             : 
     103             : #define LB_FRAME                0x00000001L // text region of the paragraph
     104             : #define LB_PRTAREA              0x00000002L // text region of the paragraph + indentions
     105             : #define LB_VERT_FRAME           0x00000004L // vertical text region of the paragraph
     106             : #define LB_VERT_PRTAREA         0x00000008L // vertival text region of the paragraph + indentions
     107             : #define LB_REL_FRM_LEFT         0x00000010L // left paragraph edge
     108             : #define LB_REL_FRM_RIGHT        0x00000020L // right paragraph edge
     109             : 
     110             : #define LB_REL_PG_LEFT          0x00000040L // left page edge
     111             : #define LB_REL_PG_RIGHT         0x00000080L    // right page edge
     112             : #define LB_REL_PG_FRAME         0x00000100L // whole page
     113             : #define LB_REL_PG_PRTAREA       0x00000200L    // text region of the page
     114             : 
     115             : #define LB_FLY_REL_PG_LEFT      0x00000400L    // left frame edge
     116             : #define LB_FLY_REL_PG_RIGHT     0x00000800L    // right frame edge
     117             : #define LB_FLY_REL_PG_FRAME     0x00001000L    // whole frame
     118             : #define LB_FLY_REL_PG_PRTAREA   0x00002000L    // inside of the frame
     119             : 
     120             : #define LB_REL_BASE             0x00010000L // character alignment Base
     121             : #define LB_REL_CHAR             0x00020000L // character alignment Character
     122             : #define LB_REL_ROW              0x00040000L // character alignment Row
     123             : 
     124             : #define LB_FLY_VERT_FRAME       0x00100000L // vertical entire frame
     125             : #define LB_FLY_VERT_PRTAREA     0x00200000L // vertical frame text area
     126             : 
     127             : #define LB_VERT_LINE            0x00400000L // vertical text line
     128             : 
     129             : static RelationMap aRelationMap[] =
     130             : {
     131             :     {SwFPos::FRAME,  SwFPos::FRAME, LB_FRAME, text::RelOrientation::FRAME},
     132             :     {SwFPos::PRTAREA,           SwFPos::PRTAREA,                LB_PRTAREA,             text::RelOrientation::PRINT_AREA},
     133             :     {SwFPos::REL_PG_LEFT,       SwFPos::MIR_REL_PG_LEFT,        LB_REL_PG_LEFT,         text::RelOrientation::PAGE_LEFT},
     134             :     {SwFPos::REL_PG_RIGHT,      SwFPos::MIR_REL_PG_RIGHT,       LB_REL_PG_RIGHT,        text::RelOrientation::PAGE_RIGHT},
     135             :     {SwFPos::REL_FRM_LEFT,      SwFPos::MIR_REL_FRM_LEFT,       LB_REL_FRM_LEFT,        text::RelOrientation::FRAME_LEFT},
     136             :     {SwFPos::REL_FRM_RIGHT,     SwFPos::MIR_REL_FRM_RIGHT,      LB_REL_FRM_RIGHT,       text::RelOrientation::FRAME_RIGHT},
     137             :     {SwFPos::REL_PG_FRAME,      SwFPos::REL_PG_FRAME,           LB_REL_PG_FRAME,        text::RelOrientation::PAGE_FRAME},
     138             :     {SwFPos::REL_PG_PRTAREA,    SwFPos::REL_PG_PRTAREA,         LB_REL_PG_PRTAREA,      text::RelOrientation::PAGE_PRINT_AREA},
     139             :     {SwFPos::REL_CHAR,          SwFPos::REL_CHAR,               LB_REL_CHAR,            text::RelOrientation::CHAR},
     140             : 
     141             :     {SwFPos::FLY_REL_PG_LEFT,       SwFPos::FLY_MIR_REL_PG_LEFT,    LB_FLY_REL_PG_LEFT,     text::RelOrientation::PAGE_LEFT},
     142             :     {SwFPos::FLY_REL_PG_RIGHT,      SwFPos::FLY_MIR_REL_PG_RIGHT,   LB_FLY_REL_PG_RIGHT,    text::RelOrientation::PAGE_RIGHT},
     143             :     {SwFPos::FLY_REL_PG_FRAME,      SwFPos::FLY_REL_PG_FRAME,       LB_FLY_REL_PG_FRAME,    text::RelOrientation::PAGE_FRAME},
     144             :     {SwFPos::FLY_REL_PG_PRTAREA,    SwFPos::FLY_REL_PG_PRTAREA,     LB_FLY_REL_PG_PRTAREA,  text::RelOrientation::PAGE_PRINT_AREA},
     145             : 
     146             :     {SwFPos::REL_BORDER,        SwFPos::REL_BORDER,             LB_VERT_FRAME,          text::RelOrientation::FRAME},
     147             :     {SwFPos::REL_PRTAREA,       SwFPos::REL_PRTAREA,            LB_VERT_PRTAREA,        text::RelOrientation::PRINT_AREA},
     148             : 
     149             :     {SwFPos::FLY_REL_PG_FRAME,      SwFPos::FLY_REL_PG_FRAME,   LB_FLY_VERT_FRAME,      text::RelOrientation::FRAME},
     150             :     {SwFPos::FLY_REL_PG_PRTAREA,    SwFPos::FLY_REL_PG_PRTAREA,     LB_FLY_VERT_PRTAREA,    text::RelOrientation::PRINT_AREA},
     151             : 
     152             :     {SwFPos::REL_LINE,  SwFPos::REL_LINE,   LB_VERT_LINE,   text::RelOrientation::TEXT_LINE}
     153             : };
     154             : 
     155             : static RelationMap aAsCharRelationMap[] =
     156             : {
     157             :     {SwFPos::REL_BASE,  SwFPos::REL_BASE,   LB_REL_BASE,    text::RelOrientation::FRAME},
     158             :     {SwFPos::REL_CHAR,   SwFPos::REL_CHAR,   LB_REL_CHAR,   text::RelOrientation::FRAME},
     159             :     {SwFPos::REL_ROW,    SwFPos::REL_ROW,   LB_REL_ROW,     text::RelOrientation::FRAME}
     160             : };
     161             : 
     162             : // site anchored
     163             : #define HORI_PAGE_REL   (LB_REL_PG_FRAME|LB_REL_PG_PRTAREA|LB_REL_PG_LEFT| \
     164             :                         LB_REL_PG_RIGHT)
     165             : 
     166             : static FrmMap aHPageMap[] =
     167             : {
     168             :     {SwFPos::LEFT,          SwFPos::MIR_LEFT,       text::HoriOrientation::LEFT,      HORI_PAGE_REL},
     169             :     {SwFPos::RIGHT,         SwFPos::MIR_RIGHT,      text::HoriOrientation::RIGHT,     HORI_PAGE_REL},
     170             :     {SwFPos::CENTER_HORI,   SwFPos::CENTER_HORI,    text::HoriOrientation::CENTER,    HORI_PAGE_REL},
     171             :     {SwFPos::FROMLEFT,      SwFPos::MIR_FROMLEFT,   text::HoriOrientation::NONE,      HORI_PAGE_REL}
     172             : };
     173             : 
     174             : static FrmMap aHPageHtmlMap[] =
     175             : {
     176             :     {SwFPos::FROMLEFT,      SwFPos::MIR_FROMLEFT,   text::HoriOrientation::NONE,      LB_REL_PG_FRAME}
     177             : };
     178             : 
     179             : #define VERT_PAGE_REL   (LB_REL_PG_FRAME|LB_REL_PG_PRTAREA)
     180             : 
     181             : static FrmMap aVPageMap[] =
     182             : {
     183             :     {SwFPos::TOP,           SwFPos::TOP,            text::VertOrientation::TOP,       VERT_PAGE_REL},
     184             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         text::VertOrientation::BOTTOM,    VERT_PAGE_REL},
     185             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    text::VertOrientation::CENTER,    VERT_PAGE_REL},
     186             :     {SwFPos::FROMTOP,       SwFPos::FROMTOP,        text::VertOrientation::NONE,      VERT_PAGE_REL}
     187             : };
     188             : 
     189             : static FrmMap aVPageHtmlMap[] =
     190             : {
     191             :     {SwFPos::FROMTOP,       SwFPos::FROMTOP,        text::VertOrientation::NONE,      LB_REL_PG_FRAME}
     192             : };
     193             : 
     194             : // frame anchored
     195             : #define HORI_FRAME_REL  (LB_FLY_REL_PG_FRAME|LB_FLY_REL_PG_PRTAREA| \
     196             :                         LB_FLY_REL_PG_LEFT|LB_FLY_REL_PG_RIGHT)
     197             : 
     198             : static FrmMap aHFrameMap[] =
     199             : {
     200             :     {SwFPos::LEFT,          SwFPos::MIR_LEFT,       text::HoriOrientation::LEFT,  HORI_FRAME_REL},
     201             :     {SwFPos::RIGHT,         SwFPos::MIR_RIGHT,      text::HoriOrientation::RIGHT,     HORI_FRAME_REL},
     202             :     {SwFPos::CENTER_HORI,   SwFPos::CENTER_HORI,    text::HoriOrientation::CENTER,    HORI_FRAME_REL},
     203             :     {SwFPos::FROMLEFT,      SwFPos::MIR_FROMLEFT,   text::HoriOrientation::NONE,      HORI_FRAME_REL}
     204             : };
     205             : 
     206             : static FrmMap aHFlyHtmlMap[] =
     207             : {
     208             :     {SwFPos::LEFT,          SwFPos::MIR_LEFT,       text::HoriOrientation::LEFT,      LB_FLY_REL_PG_FRAME},
     209             :     {SwFPos::FROMLEFT,      SwFPos::MIR_FROMLEFT,   text::HoriOrientation::NONE,      LB_FLY_REL_PG_FRAME}
     210             : };
     211             : 
     212             : // own vertical alignment map for objects anchored to frame
     213             : #define VERT_FRAME_REL   (LB_FLY_VERT_FRAME|LB_FLY_VERT_PRTAREA)
     214             : 
     215             : static FrmMap aVFrameMap[] =
     216             : {
     217             :     {SwFPos::TOP,           SwFPos::TOP,            text::VertOrientation::TOP,       VERT_FRAME_REL},
     218             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         text::VertOrientation::BOTTOM,    VERT_FRAME_REL},
     219             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    text::VertOrientation::CENTER,    VERT_FRAME_REL},
     220             :     {SwFPos::FROMTOP,       SwFPos::FROMTOP,        text::VertOrientation::NONE,      VERT_FRAME_REL}
     221             : };
     222             : 
     223             : static FrmMap aVFlyHtmlMap[] =
     224             : {
     225             :     {SwFPos::TOP,           SwFPos::TOP,            text::VertOrientation::TOP,       LB_FLY_VERT_FRAME},
     226             :     {SwFPos::FROMTOP,       SwFPos::FROMTOP,        text::VertOrientation::NONE,      LB_FLY_VERT_FRAME}
     227             : };
     228             : 
     229             : // paragraph anchored
     230             : #define HORI_PARA_REL   (LB_FRAME|LB_PRTAREA|LB_REL_PG_LEFT|LB_REL_PG_RIGHT| \
     231             :                         LB_REL_PG_FRAME|LB_REL_PG_PRTAREA|LB_REL_FRM_LEFT| \
     232             :                         LB_REL_FRM_RIGHT)
     233             : 
     234             : static FrmMap aHParaMap[] =
     235             : {
     236             :     {SwFPos::LEFT,          SwFPos::MIR_LEFT,       text::HoriOrientation::LEFT,      HORI_PARA_REL},
     237             :     {SwFPos::RIGHT,         SwFPos::MIR_RIGHT,      text::HoriOrientation::RIGHT,     HORI_PARA_REL},
     238             :     {SwFPos::CENTER_HORI,   SwFPos::CENTER_HORI,    text::HoriOrientation::CENTER,    HORI_PARA_REL},
     239             :     {SwFPos::FROMLEFT,      SwFPos::MIR_FROMLEFT,   text::HoriOrientation::NONE,      HORI_PARA_REL}
     240             : };
     241             : 
     242             : #define HTML_HORI_PARA_REL  (LB_FRAME|LB_PRTAREA)
     243             : 
     244             : static FrmMap aHParaHtmlMap[] =
     245             : {
     246             :     {SwFPos::LEFT,  SwFPos::LEFT,   text::HoriOrientation::LEFT,      HTML_HORI_PARA_REL},
     247             :     {SwFPos::RIGHT, SwFPos::RIGHT,  text::HoriOrientation::RIGHT,     HTML_HORI_PARA_REL}
     248             : };
     249             : 
     250             : static FrmMap aHParaHtmlAbsMap[] =
     251             : {
     252             :     {SwFPos::LEFT,          SwFPos::MIR_LEFT,       text::HoriOrientation::LEFT,      HTML_HORI_PARA_REL},
     253             :     {SwFPos::RIGHT,         SwFPos::MIR_RIGHT,      text::HoriOrientation::RIGHT,     HTML_HORI_PARA_REL}
     254             : };
     255             : 
     256             : // allow vertical alignment at page areas
     257             : #define VERT_PARA_REL   (LB_VERT_FRAME|LB_VERT_PRTAREA| \
     258             :                          LB_REL_PG_FRAME|LB_REL_PG_PRTAREA)
     259             : 
     260             : static FrmMap aVParaMap[] =
     261             : {
     262             :     {SwFPos::TOP,           SwFPos::TOP,            text::VertOrientation::TOP,       VERT_PARA_REL},
     263             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         text::VertOrientation::BOTTOM,    VERT_PARA_REL},
     264             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    text::VertOrientation::CENTER,    VERT_PARA_REL},
     265             :     {SwFPos::FROMTOP,       SwFPos::FROMTOP,        text::VertOrientation::NONE,      VERT_PARA_REL}
     266             : };
     267             : 
     268             : static FrmMap aVParaHtmlMap[] =
     269             : {
     270             :     {SwFPos::TOP,           SwFPos::TOP,            text::VertOrientation::TOP,       LB_VERT_PRTAREA}
     271             : };
     272             : 
     273             : // anchored relative to the character
     274             : #define HORI_CHAR_REL   (LB_FRAME|LB_PRTAREA|LB_REL_PG_LEFT|LB_REL_PG_RIGHT| \
     275             :                         LB_REL_PG_FRAME|LB_REL_PG_PRTAREA|LB_REL_FRM_LEFT| \
     276             :                         LB_REL_FRM_RIGHT|LB_REL_CHAR)
     277             : 
     278             : static FrmMap aHCharMap[] =
     279             : {
     280             :     {SwFPos::LEFT,          SwFPos::MIR_LEFT,       text::HoriOrientation::LEFT,      HORI_CHAR_REL},
     281             :     {SwFPos::RIGHT,         SwFPos::MIR_RIGHT,      text::HoriOrientation::RIGHT,     HORI_CHAR_REL},
     282             :     {SwFPos::CENTER_HORI,   SwFPos::CENTER_HORI,    text::HoriOrientation::CENTER,    HORI_CHAR_REL},
     283             :     {SwFPos::FROMLEFT,      SwFPos::MIR_FROMLEFT,   text::HoriOrientation::NONE,      HORI_CHAR_REL}
     284             : };
     285             : 
     286             : #define HTML_HORI_CHAR_REL  (LB_FRAME|LB_PRTAREA|LB_REL_CHAR)
     287             : 
     288             : static FrmMap aHCharHtmlMap[] =
     289             : {
     290             :     {SwFPos::LEFT,          SwFPos::LEFT,           text::HoriOrientation::LEFT,      HTML_HORI_CHAR_REL},
     291             :     {SwFPos::RIGHT,         SwFPos::RIGHT,          text::HoriOrientation::RIGHT,     HTML_HORI_CHAR_REL}
     292             : };
     293             : 
     294             : static FrmMap aHCharHtmlAbsMap[] =
     295             : {
     296             :     {SwFPos::LEFT,          SwFPos::MIR_LEFT,       text::HoriOrientation::LEFT,      LB_PRTAREA|LB_REL_CHAR},
     297             :     {SwFPos::RIGHT,         SwFPos::MIR_RIGHT,      text::HoriOrientation::RIGHT,     LB_PRTAREA},
     298             :     {SwFPos::FROMLEFT,      SwFPos::MIR_FROMLEFT,   text::HoriOrientation::NONE,      LB_REL_PG_FRAME}
     299             : };
     300             : 
     301             : // allow vertical alignment at page areas
     302             : #define VERT_CHAR_REL   (LB_VERT_FRAME|LB_VERT_PRTAREA| \
     303             :                          LB_REL_PG_FRAME|LB_REL_PG_PRTAREA)
     304             : 
     305             : static FrmMap aVCharMap[] =
     306             : {
     307             :     // introduce mappings for new vertical alignment at top of line <LB_VERT_LINE>
     308             :     // and correct mapping for vertical alignment at character for position <FROM_BOTTOM>
     309             :     // Note: Because of these adjustments the map becomes ambigous in its values
     310             :     //       <eStrId>/<eMirrorStrId> and <nAlign>. These ambiguities are considered
     311             :     //       in the methods <SwFrmPage::FillRelLB(..)>, <SwFrmPage::GetAlignment(..)>
     312             :     //       and <SwFrmPage::FillPosLB(..)>
     313             :     {SwFPos::TOP,           SwFPos::TOP,            text::VertOrientation::TOP,           VERT_CHAR_REL|LB_REL_CHAR},
     314             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         text::VertOrientation::BOTTOM,        VERT_CHAR_REL|LB_REL_CHAR},
     315             :     {SwFPos::BELOW,         SwFPos::BELOW,          text::VertOrientation::CHAR_BOTTOM,   LB_REL_CHAR},
     316             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    text::VertOrientation::CENTER,        VERT_CHAR_REL|LB_REL_CHAR},
     317             :     {SwFPos::FROMTOP,       SwFPos::FROMTOP,        text::VertOrientation::NONE,          VERT_CHAR_REL},
     318             :     {SwFPos::FROMBOTTOM,    SwFPos::FROMBOTTOM,     text::VertOrientation::NONE,          LB_REL_CHAR|LB_VERT_LINE},
     319             :     {SwFPos::TOP,           SwFPos::TOP,            text::VertOrientation::LINE_TOP,      LB_VERT_LINE},
     320             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         text::VertOrientation::LINE_BOTTOM,   LB_VERT_LINE},
     321             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    text::VertOrientation::LINE_CENTER,   LB_VERT_LINE}
     322             : };
     323             : 
     324             : static FrmMap aVCharHtmlMap[] =
     325             : {
     326             :     {SwFPos::BELOW,         SwFPos::BELOW,          text::VertOrientation::CHAR_BOTTOM,   LB_REL_CHAR}
     327             : };
     328             : 
     329             : static FrmMap aVCharHtmlAbsMap[] =
     330             : {
     331             :     {SwFPos::TOP,           SwFPos::TOP,            text::VertOrientation::TOP,           LB_REL_CHAR},
     332             :     {SwFPos::BELOW,             SwFPos::BELOW,          text::VertOrientation::CHAR_BOTTOM,   LB_REL_CHAR}
     333             : };
     334             : 
     335             : // anchored as character
     336             : static FrmMap aVAsCharMap[] =
     337             : {
     338             :     {SwFPos::TOP,               SwFPos::TOP,            text::VertOrientation::TOP,           LB_REL_BASE},
     339             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         text::VertOrientation::BOTTOM,        LB_REL_BASE},
     340             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    text::VertOrientation::CENTER,        LB_REL_BASE},
     341             : 
     342             :     {SwFPos::TOP,               SwFPos::TOP,            text::VertOrientation::CHAR_TOP,      LB_REL_CHAR},
     343             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         text::VertOrientation::CHAR_BOTTOM,   LB_REL_CHAR},
     344             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    text::VertOrientation::CHAR_CENTER,   LB_REL_CHAR},
     345             : 
     346             :     {SwFPos::TOP,               SwFPos::TOP,            text::VertOrientation::LINE_TOP,      LB_REL_ROW},
     347             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         text::VertOrientation::LINE_BOTTOM,   LB_REL_ROW},
     348             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    text::VertOrientation::LINE_CENTER,   LB_REL_ROW},
     349             : 
     350             :     {SwFPos::FROMBOTTOM,    SwFPos::FROMBOTTOM,     text::VertOrientation::NONE,          LB_REL_BASE}
     351             : };
     352             : 
     353             : static FrmMap aVAsCharHtmlMap[] =
     354             : {
     355             :     {SwFPos::TOP,               SwFPos::TOP,            text::VertOrientation::TOP,           LB_REL_BASE},
     356             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    text::VertOrientation::CENTER,        LB_REL_BASE},
     357             : 
     358             :     {SwFPos::TOP,               SwFPos::TOP,            text::VertOrientation::CHAR_TOP,      LB_REL_CHAR},
     359             : 
     360             :     {SwFPos::TOP,               SwFPos::TOP,            text::VertOrientation::LINE_TOP,      LB_REL_ROW},
     361             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         text::VertOrientation::LINE_BOTTOM,   LB_REL_ROW},
     362             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    text::VertOrientation::LINE_CENTER,   LB_REL_ROW}
     363             : };
     364             : 
     365             : static const sal_uInt16 aPageRg[] = {
     366             :     RES_FRM_SIZE, RES_FRM_SIZE,
     367             :     RES_VERT_ORIENT, RES_ANCHOR,
     368             :     RES_COL, RES_COL,
     369             :     RES_FOLLOW_TEXT_FLOW, RES_FOLLOW_TEXT_FLOW,
     370             :     0
     371             : };
     372             : static const sal_uInt16 aAddPgRg[] = {
     373             :     RES_PROTECT,            RES_PROTECT,
     374             :     RES_PRINT,              RES_PRINT,
     375             :     FN_SET_FRM_NAME,        FN_SET_FRM_NAME,
     376             :     FN_SET_FRM_ALT_NAME,    FN_SET_FRM_ALT_NAME,
     377             :     0
     378             : };
     379             : 
     380           0 : static size_t lcl_GetFrmMapCount( const FrmMap* pMap)
     381             : {
     382           0 :     if ( pMap )
     383             :     {
     384           0 :         if( pMap == aVParaHtmlMap)
     385           0 :             return SAL_N_ELEMENTS(aVParaHtmlMap);
     386           0 :         if( pMap == aVAsCharHtmlMap)
     387           0 :             return SAL_N_ELEMENTS(aVAsCharHtmlMap);
     388           0 :         if( pMap == aHParaHtmlMap)
     389           0 :             return SAL_N_ELEMENTS(aHParaHtmlMap);
     390           0 :         if( pMap == aHParaHtmlAbsMap)
     391           0 :             return SAL_N_ELEMENTS(aHParaHtmlAbsMap);
     392           0 :         if ( pMap == aVPageMap )
     393           0 :             return SAL_N_ELEMENTS(aVPageMap);
     394           0 :         if ( pMap == aVPageHtmlMap )
     395           0 :             return SAL_N_ELEMENTS(aVPageHtmlMap);
     396           0 :         if ( pMap == aVAsCharMap )
     397           0 :             return SAL_N_ELEMENTS(aVAsCharMap);
     398           0 :         if ( pMap == aVParaMap )
     399           0 :             return SAL_N_ELEMENTS(aVParaMap);
     400           0 :         if ( pMap == aHParaMap )
     401           0 :             return SAL_N_ELEMENTS(aHParaMap);
     402           0 :         if ( pMap == aHFrameMap )
     403           0 :             return SAL_N_ELEMENTS(aHFrameMap);
     404           0 :         if ( pMap == aVFrameMap )
     405           0 :             return SAL_N_ELEMENTS(aVFrameMap);
     406           0 :         if ( pMap == aHCharMap )
     407           0 :             return SAL_N_ELEMENTS(aHCharMap);
     408           0 :         if ( pMap == aHCharHtmlMap )
     409           0 :             return SAL_N_ELEMENTS(aHCharHtmlMap);
     410           0 :         if ( pMap == aHCharHtmlAbsMap )
     411           0 :             return SAL_N_ELEMENTS(aHCharHtmlAbsMap);
     412           0 :         if ( pMap == aVCharMap )
     413           0 :             return SAL_N_ELEMENTS(aVCharMap);
     414           0 :         if ( pMap == aVCharHtmlMap )
     415           0 :             return SAL_N_ELEMENTS(aVCharHtmlMap);
     416           0 :         if ( pMap == aVCharHtmlAbsMap )
     417           0 :             return SAL_N_ELEMENTS(aVCharHtmlAbsMap);
     418           0 :         if ( pMap == aHPageHtmlMap )
     419           0 :             return SAL_N_ELEMENTS(aHPageHtmlMap);
     420           0 :         if ( pMap == aHFlyHtmlMap )
     421           0 :             return SAL_N_ELEMENTS(aHFlyHtmlMap);
     422           0 :         if ( pMap == aVFlyHtmlMap )
     423           0 :             return SAL_N_ELEMENTS(aVFlyHtmlMap);
     424           0 :         return SAL_N_ELEMENTS(aHPageMap);
     425             :     }
     426           0 :     return 0;
     427             : }
     428             : 
     429           0 : static void lcl_InsertVectors(ListBox& rBox,
     430             :     const ::std::vector< OUString >& rPrev, const ::std::vector< OUString >& rThis,
     431             :     const ::std::vector< OUString >& rNext, const ::std::vector< OUString >& rRemain)
     432             : {
     433           0 :     ::std::vector< OUString >::const_iterator aIt;
     434           0 :     sal_Int32 nEntry = 0;
     435           0 :     for(aIt = rPrev.begin(); aIt != rPrev.end(); ++aIt)
     436           0 :         nEntry = rBox.InsertEntry(*aIt);
     437           0 :     for(aIt = rThis.begin(); aIt != rThis.end(); ++aIt)
     438           0 :         nEntry = rBox.InsertEntry(*aIt);
     439           0 :     for(aIt = rNext.begin(); aIt != rNext.end(); ++aIt)
     440           0 :         nEntry = rBox.InsertEntry(*aIt);
     441           0 :     rBox.SetSeparatorPos(nEntry);
     442             :     //now insert all strings sorted
     443           0 :     const sal_Int32 nStartPos = rBox.GetEntryCount();
     444             : 
     445           0 :     for(aIt = rPrev.begin(); aIt != rPrev.end(); ++aIt)
     446           0 :         ::InsertStringSorted(*aIt, rBox, nStartPos );
     447           0 :     for(aIt = rThis.begin(); aIt != rThis.end(); ++aIt)
     448           0 :         ::InsertStringSorted(*aIt, rBox, nStartPos );
     449           0 :     for(aIt = rNext.begin(); aIt != rNext.end(); ++aIt)
     450           0 :         ::InsertStringSorted(*aIt, rBox, nStartPos );
     451           0 :     for(aIt = rRemain.begin(); aIt != rRemain.end(); ++aIt)
     452           0 :         ::InsertStringSorted(*aIt, rBox, nStartPos );
     453           0 : }
     454             : 
     455             : // --> OD 2009-08-31 #mongolianlayout#
     456             : // add input parameter
     457           0 : static SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL(SvxSwFramePosString::StringId eStringId, bool bVertical, bool bVerticalL2R, bool bRTL)
     458             : {
     459             :     //special handling of STR_FROMLEFT
     460           0 :     if ( SwFPos::FROMLEFT == eStringId )
     461             :     {
     462             :         eStringId = bVertical
     463             :                     ? ( bRTL
     464             :                         ? SwFPos::FROMBOTTOM
     465             :                         : SwFPos::FROMTOP )
     466             :                     : ( bRTL
     467             :                         ? SwFPos::FROMRIGHT
     468           0 :                         : SwFPos::FROMLEFT );
     469           0 :         return eStringId;
     470             :     }
     471             :     // --> OD 2009-08-31 #mongolianlayout#
     472             :     // special handling of STR_FROMTOP in case of mongolianlayout (vertical left-to-right)
     473           0 :     if ( SwFPos::FROMTOP == eStringId &&
     474           0 :          bVertical && bVerticalL2R )
     475             :     {
     476           0 :         eStringId = SwFPos::FROMLEFT;
     477           0 :         return eStringId;
     478             :     }
     479           0 :     if ( bVertical )
     480             :     {
     481             :         //exchange horizontal strings with vertical strings and vice versa
     482             :         static const StringIdPair_Impl aHoriIds[] =
     483             :         {
     484             :             {SwFPos::LEFT,           SwFPos::TOP},
     485             :             {SwFPos::RIGHT,          SwFPos::BOTTOM},
     486             :             {SwFPos::CENTER_HORI,    SwFPos::CENTER_VERT},
     487             :             {SwFPos::FROMTOP,        SwFPos::FROMRIGHT},
     488             :             {SwFPos::REL_PG_LEFT,    SwFPos::REL_PG_TOP},
     489             :             {SwFPos::REL_PG_RIGHT,   SwFPos::REL_PG_BOTTOM} ,
     490             :             {SwFPos::REL_FRM_LEFT,   SwFPos::REL_FRM_TOP},
     491             :             {SwFPos::REL_FRM_RIGHT,  SwFPos::REL_FRM_BOTTOM}
     492             :         };
     493             :         static const StringIdPair_Impl aVertIds[] =
     494             :         {
     495             :             {SwFPos::TOP,            SwFPos::RIGHT},
     496             :             {SwFPos::BOTTOM,         SwFPos::LEFT },
     497             :             {SwFPos::CENTER_VERT,    SwFPos::CENTER_HORI},
     498             :             {SwFPos::FROMTOP,        SwFPos::FROMRIGHT },
     499             :             {SwFPos::REL_PG_TOP,     SwFPos::REL_PG_LEFT },
     500             :             {SwFPos::REL_PG_BOTTOM,  SwFPos::REL_PG_RIGHT } ,
     501             :             {SwFPos::REL_FRM_TOP,    SwFPos::REL_FRM_LEFT },
     502             :             {SwFPos::REL_FRM_BOTTOM, SwFPos::REL_FRM_RIGHT }
     503             :         };
     504             :         // --> OD 2009-08-31 #monglianlayout#
     505             :         static const StringIdPair_Impl aVertL2RIds[] =
     506             :         {
     507             :             {SwFPos::TOP,            SwFPos::LEFT },
     508             :             {SwFPos::BOTTOM,         SwFPos::RIGHT },
     509             :             {SwFPos::CENTER_VERT,    SwFPos::CENTER_HORI },
     510             :             {SwFPos::FROMTOP,        SwFPos::FROMLEFT },
     511             :             {SwFPos::REL_PG_TOP,     SwFPos::REL_PG_LEFT },
     512             :             {SwFPos::REL_PG_BOTTOM,  SwFPos::REL_PG_RIGHT } ,
     513             :             {SwFPos::REL_FRM_TOP,    SwFPos::REL_FRM_LEFT },
     514             :             {SwFPos::REL_FRM_BOTTOM, SwFPos::REL_FRM_RIGHT }
     515             :         };
     516           0 :         for(size_t nIndex = 0; nIndex < SAL_N_ELEMENTS(aHoriIds); ++nIndex)
     517             :         {
     518           0 :             if(aHoriIds[nIndex].eHori == eStringId)
     519             :             {
     520           0 :                 eStringId = aHoriIds[nIndex].eVert;
     521           0 :                 return eStringId;
     522             :             }
     523             :         }
     524           0 :         for(size_t nIndex = 0; nIndex < SAL_N_ELEMENTS(aVertIds); ++nIndex)
     525             :         {
     526             :             // --> OD 2009-08-31 #mongolianlayout#
     527           0 :             if ( !bVerticalL2R )
     528             :             {
     529           0 :                 if(aVertIds[nIndex].eHori == eStringId)
     530             :                 {
     531           0 :                     eStringId = aVertIds[nIndex].eVert;
     532           0 :                     break;
     533             :                 }
     534             :             }
     535             :             else
     536             :             {
     537           0 :                 if(aVertL2RIds[nIndex].eHori == eStringId)
     538             :                 {
     539           0 :                     eStringId = aVertL2RIds[nIndex].eVert;
     540           0 :                     break;
     541             :                 }
     542             :             }
     543             :         }
     544             :     }
     545           0 :     return eStringId;
     546             : }
     547             : 
     548             : // helper method in order to determine all possible
     549             : // listbox relations in a relation map for a given relation
     550           0 : static sal_uLong lcl_GetLBRelationsForRelations( const sal_Int16 _nRel )
     551             : {
     552           0 :     sal_uLong nLBRelations = 0L;
     553             : 
     554           0 :     const size_t nRelMapSize = SAL_N_ELEMENTS(aRelationMap);
     555           0 :     for ( size_t nRelMapPos = 0; nRelMapPos < nRelMapSize; ++nRelMapPos )
     556             :     {
     557           0 :         if ( aRelationMap[nRelMapPos].nRelation == _nRel )
     558             :         {
     559           0 :             nLBRelations |= aRelationMap[nRelMapPos].nLBRelation;
     560             :         }
     561             :     }
     562             : 
     563           0 :     return nLBRelations;
     564             : }
     565             : 
     566             : // helper method on order to determine all possible
     567             : // listbox relations in a relation map for a given string ID
     568           0 : static sal_uLong lcl_GetLBRelationsForStrID( const FrmMap* _pMap,
     569             :                                              const SvxSwFramePosString::StringId _eStrId,
     570             :                                              const bool _bUseMirrorStr )
     571             : {
     572           0 :     sal_uLong nLBRelations = 0L;
     573             : 
     574           0 :     size_t nRelMapSize = lcl_GetFrmMapCount( _pMap );
     575           0 :     for ( size_t nRelMapPos = 0; nRelMapPos < nRelMapSize; ++nRelMapPos )
     576             :     {
     577           0 :         if ( ( !_bUseMirrorStr && _pMap[nRelMapPos].eStrId == _eStrId ) ||
     578           0 :              ( _bUseMirrorStr && _pMap[nRelMapPos].eMirrorStrId == _eStrId ) )
     579             :         {
     580           0 :             nLBRelations |= _pMap[nRelMapPos].nLBRelations;
     581             :         }
     582             :     }
     583             : 
     584           0 :     return nLBRelations;
     585             : }
     586             : 
     587             : // standard frame TabPage
     588             : namespace
     589             : {
     590           0 :     void HandleAutoCB( bool _bChecked, FixedText& _rFT_man, FixedText& _rFT_auto, MetricField& _rPF_Edit)
     591             :     {
     592           0 :         _rFT_man.Show( !_bChecked );
     593           0 :         _rFT_auto.Show( _bChecked );
     594           0 :         OUString accName = _bChecked ? _rFT_auto.GetText() : _rFT_man.GetText();
     595           0 :         _rPF_Edit.SetAccessibleName(accName);
     596           0 :     }
     597             : }
     598             : 
     599           0 : SwFrmPage::SwFrmPage(vcl::Window *pParent, const SfxItemSet &rSet)
     600             :     : SfxTabPage(pParent, "FrmTypePage",
     601             :         "modules/swriter/ui/frmtypepage.ui", &rSet)
     602             :     ,
     603             :     bAtHorzPosModified( false ),
     604             :     bAtVertPosModified( false ),
     605             :     bFormat(false),
     606             :     bNew(true),
     607             :     bNoModifyHdl(true),
     608             :     // --> OD 2009-08-31 #mongolianlayout# - no used
     609             : //    bVerticalChanged(sal_False),
     610             :     bIsVerticalFrame(false),
     611             :     bIsVerticalL2R(false),
     612             :     bIsInRightToLeft(false),
     613             :     bHtmlMode(false),
     614             :     nHtmlMode(0),
     615             :     nUpperBorder(0),
     616             :     nLowerBorder(0),
     617             :     fWidthHeightRatio(1.0),
     618             :     mpToCharCntntPos( NULL ),
     619             : 
     620             :     nOldH(text::HoriOrientation::CENTER),
     621             :     nOldHRel(text::RelOrientation::FRAME),
     622             :     nOldV(text::VertOrientation::TOP),
     623             :     nOldVRel(text::RelOrientation::PRINT_AREA),
     624             :     pVMap( 0 ),
     625             :     pHMap( 0 ),
     626             :     m_bAllowVertPositioning( true ),
     627             :     m_bIsMathOLE( false ),
     628           0 :     m_bIsMathBaselineAlignment( true )
     629             : {
     630           0 :     get(m_pWidthFT, "widthft");
     631           0 :     get(m_pWidthAutoFT, "autowidthft");
     632           0 :     m_aWidthED.set(get<MetricField>("width"));
     633           0 :     get(m_pRelWidthCB, "relwidth");
     634           0 :     get(m_pRelWidthRelationLB, "relwidthrelation");
     635           0 :     get(m_pAutoWidthCB, "autowidth");
     636             : 
     637           0 :     get(m_pHeightFT, "heightft");
     638           0 :     get(m_pHeightAutoFT, "autoheightft");
     639           0 :     m_aHeightED.set(get<MetricField>("height"));
     640           0 :     get(m_pRelHeightCB, "relheight");
     641           0 :     get(m_pRelHeightRelationLB, "relheightrelation");
     642           0 :     get(m_pAutoHeightCB, "autoheight");
     643             : 
     644           0 :     get(m_pFixedRatioCB, "ratio");
     645           0 :     get(m_pRealSizeBT, "origsize");
     646             : 
     647           0 :     get(m_pAnchorFrame, "anchorframe");
     648           0 :     get(m_pAnchorAtPageRB, "topage");
     649           0 :     get(m_pAnchorAtParaRB, "topara");
     650           0 :     get(m_pAnchorAtCharRB, "tochar");
     651           0 :     get(m_pAnchorAsCharRB, "aschar");
     652           0 :     get(m_pAnchorAtFrameRB, "toframe");
     653             : 
     654           0 :     get(m_pHorizontalFT, "horiposft");
     655           0 :     get(m_pHorizontalDLB, "horipos");
     656           0 :     get(m_pAtHorzPosFT, "horibyft");
     657           0 :     get(m_pAtHorzPosED, "byhori");
     658           0 :     get(m_pHoriRelationFT, "horitoft");
     659           0 :     get(m_pHoriRelationLB, "horianchor");
     660             : 
     661           0 :     get(m_pMirrorPagesCB, "mirror");
     662             : 
     663           0 :     get(m_pVerticalFT, "vertposft");
     664           0 :     get(m_pVerticalDLB, "vertpos");
     665           0 :     get(m_pAtVertPosFT, "vertbyft");
     666           0 :     get(m_pAtVertPosED, "byvert");
     667           0 :     get(m_pVertRelationFT, "verttoft");
     668           0 :     get(m_pVertRelationLB, "vertanchor");
     669             : 
     670           0 :     get(m_pFollowTextFlowCB, "followtextflow");
     671           0 :     get(m_pExampleWN, "preview");
     672             : 
     673           0 :     m_pAtHorzPosED->set_width_request(m_pAtHorzPosED->GetOptimalSize().Width());
     674           0 :     m_pAtHorzPosED->set_width_request(m_pAtVertPosED->GetOptimalSize().Width());
     675             : 
     676           0 :     setOptimalFrmWidth();
     677           0 :     setOptimalRelWidth();
     678             : 
     679           0 :     SetExchangeSupport();
     680             : 
     681           0 :     Link aLk = LINK(this, SwFrmPage, RangeModifyHdl);
     682           0 :     m_aWidthED.SetLoseFocusHdl( aLk );
     683           0 :     m_aHeightED.SetLoseFocusHdl( aLk );
     684           0 :     m_pAtHorzPosED->SetLoseFocusHdl( aLk );
     685           0 :     m_pAtVertPosED->SetLoseFocusHdl( aLk );
     686           0 :     m_pFollowTextFlowCB->SetClickHdl( aLk );
     687             : 
     688           0 :     aLk = LINK(this, SwFrmPage, ModifyHdl);
     689           0 :     m_aWidthED.SetModifyHdl( aLk );
     690           0 :     m_aHeightED.SetModifyHdl( aLk );
     691           0 :     m_pAtHorzPosED->SetModifyHdl( aLk );
     692           0 :     m_pAtVertPosED->SetModifyHdl( aLk );
     693             : 
     694           0 :     aLk = LINK(this, SwFrmPage, AnchorTypeHdl);
     695           0 :     m_pAnchorAtPageRB->SetClickHdl( aLk );
     696           0 :     m_pAnchorAtParaRB->SetClickHdl( aLk );
     697           0 :     m_pAnchorAtCharRB->SetClickHdl( aLk );
     698           0 :     m_pAnchorAsCharRB->SetClickHdl( aLk );
     699           0 :     m_pAnchorAtFrameRB->SetClickHdl( aLk );
     700             : 
     701           0 :     m_pHorizontalDLB->SetSelectHdl(LINK(this, SwFrmPage, PosHdl));
     702           0 :     m_pVerticalDLB->  SetSelectHdl(LINK(this, SwFrmPage, PosHdl));
     703             : 
     704           0 :     m_pHoriRelationLB->SetSelectHdl(LINK(this, SwFrmPage, RelHdl));
     705           0 :     m_pVertRelationLB->SetSelectHdl(LINK(this, SwFrmPage, RelHdl));
     706             : 
     707           0 :     m_pMirrorPagesCB->SetClickHdl(LINK(this, SwFrmPage, MirrorHdl));
     708             : 
     709           0 :     aLk = LINK(this, SwFrmPage, RelSizeClickHdl);
     710           0 :     m_pRelWidthCB->SetClickHdl( aLk );
     711           0 :     m_pRelHeightCB->SetClickHdl( aLk );
     712             : 
     713           0 :     m_pAutoWidthCB->SetClickHdl( LINK( this, SwFrmPage, AutoWidthClickHdl ) );
     714           0 :     m_pAutoHeightCB->SetClickHdl( LINK( this, SwFrmPage, AutoHeightClickHdl ) );
     715           0 : }
     716             : 
     717             : namespace
     718             : {
     719             :     struct FrmMaps
     720             :     {
     721             :         FrmMap *pMap;
     722             :         size_t nCount;
     723             :     };
     724             : }
     725             : 
     726           0 : void SwFrmPage::setOptimalFrmWidth()
     727             : {
     728             :     const FrmMaps aMaps[] = {
     729             :         { aHPageMap, SAL_N_ELEMENTS(aHPageMap) },
     730             :         { aHPageHtmlMap, SAL_N_ELEMENTS(aHPageHtmlMap) },
     731             :         { aVPageMap, SAL_N_ELEMENTS(aVPageMap) },
     732             :         { aVPageHtmlMap, SAL_N_ELEMENTS(aVPageHtmlMap) },
     733             :         { aHFrameMap, SAL_N_ELEMENTS(aHFrameMap) },
     734             :         { aHFlyHtmlMap, SAL_N_ELEMENTS(aHFlyHtmlMap) },
     735             :         { aVFrameMap, SAL_N_ELEMENTS(aVFrameMap) },
     736             :         { aVFlyHtmlMap, SAL_N_ELEMENTS(aVFrameMap) },
     737             :         { aHParaMap, SAL_N_ELEMENTS(aHParaMap) },
     738             :         { aHParaHtmlMap, SAL_N_ELEMENTS(aHParaHtmlMap) },
     739             :         { aHParaHtmlAbsMap, SAL_N_ELEMENTS(aHParaHtmlAbsMap) },
     740             :         { aVParaMap, SAL_N_ELEMENTS(aVParaMap) },
     741             :         { aVParaHtmlMap, SAL_N_ELEMENTS(aVParaHtmlMap) },
     742             :         { aHCharMap, SAL_N_ELEMENTS(aHCharMap) },
     743             :         { aHCharHtmlMap, SAL_N_ELEMENTS(aHCharHtmlMap) },
     744             :         { aHCharHtmlAbsMap, SAL_N_ELEMENTS(aHCharHtmlAbsMap) },
     745             :         { aVCharMap, SAL_N_ELEMENTS(aVCharMap) },
     746             :         { aVCharHtmlMap, SAL_N_ELEMENTS(aVCharHtmlMap) },
     747             :         { aVCharHtmlAbsMap, SAL_N_ELEMENTS(aVCharHtmlAbsMap) },
     748             :         { aVAsCharMap, SAL_N_ELEMENTS(aVAsCharMap) },
     749             :         { aVAsCharHtmlMap, SAL_N_ELEMENTS(aVAsCharHtmlMap) }
     750           0 :     };
     751             : 
     752           0 :     std::vector<SvxSwFramePosString::StringId> aFrames;
     753           0 :     for (size_t i = 0; i < SAL_N_ELEMENTS(aMaps); ++i)
     754             :     {
     755           0 :         for (size_t j = 0; j < aMaps[i].nCount; ++j)
     756             :         {
     757           0 :             aFrames.push_back(aMaps[i].pMap[j].eStrId);
     758           0 :             aFrames.push_back(aMaps[i].pMap[j].eMirrorStrId);
     759             :         }
     760             :     }
     761             : 
     762           0 :     std::sort(aFrames.begin(), aFrames.end());
     763           0 :     aFrames.erase(std::unique(aFrames.begin(), aFrames.end()), aFrames.end());
     764             : 
     765           0 :     for (std::vector<SvxSwFramePosString::StringId>::const_iterator aI = aFrames.begin(), aEnd = aFrames.end();
     766             :         aI != aEnd; ++aI)
     767             :     {
     768           0 :         m_pHorizontalDLB->InsertEntry(aFramePosString.GetString(*aI));
     769             :     }
     770             : 
     771           0 :     Size aBiggest(m_pHorizontalDLB->GetOptimalSize());
     772           0 :     m_pHorizontalDLB->set_width_request(aBiggest.Width());
     773           0 :     m_pVerticalDLB->set_width_request(aBiggest.Width());
     774           0 :     m_pHorizontalDLB->Clear();
     775           0 : }
     776             : 
     777             : namespace
     778             : {
     779             :     struct RelationMaps
     780             :     {
     781             :         RelationMap *pMap;
     782             :         size_t nCount;
     783             :     };
     784             : }
     785             : 
     786           0 : void SwFrmPage::setOptimalRelWidth()
     787             : {
     788             :     const RelationMaps aMaps[] = {
     789             :         { aRelationMap, SAL_N_ELEMENTS(aRelationMap) },
     790             :         { aAsCharRelationMap, SAL_N_ELEMENTS(aAsCharRelationMap) }
     791           0 :     };
     792             : 
     793           0 :     std::vector<SvxSwFramePosString::StringId> aRels;
     794           0 :     for (size_t i = 0; i < SAL_N_ELEMENTS(aMaps); ++i)
     795             :     {
     796           0 :         for (size_t j = 0; j < aMaps[i].nCount; ++j)
     797             :         {
     798           0 :             aRels.push_back(aMaps[i].pMap[j].eStrId);
     799           0 :             aRels.push_back(aMaps[i].pMap[j].eMirrorStrId);
     800             :         }
     801             :     }
     802             : 
     803           0 :     std::sort(aRels.begin(), aRels.end());
     804           0 :     aRels.erase(std::unique(aRels.begin(), aRels.end()), aRels.end());
     805             : 
     806           0 :     for (std::vector<SvxSwFramePosString::StringId>::const_iterator aI = aRels.begin(), aEnd = aRels.end();
     807             :         aI != aEnd; ++aI)
     808             :     {
     809           0 :         m_pHoriRelationLB->InsertEntry(aFramePosString.GetString(*aI));
     810             :     }
     811             : 
     812           0 :     Size aBiggest(m_pHoriRelationLB->GetOptimalSize());
     813           0 :     m_pHoriRelationLB->set_width_request(aBiggest.Width());
     814           0 :     m_pVertRelationLB->set_width_request(aBiggest.Width());
     815           0 :     m_pRelWidthRelationLB->set_width_request(aBiggest.Width());
     816           0 :     m_pRelHeightRelationLB->set_width_request(aBiggest.Width());
     817           0 :     m_pHoriRelationLB->Clear();
     818           0 : }
     819             : 
     820           0 : SwFrmPage::~SwFrmPage()
     821             : {
     822           0 : }
     823             : 
     824           0 : SfxTabPage* SwFrmPage::Create(vcl::Window *pParent, const SfxItemSet *rSet)
     825             : {
     826           0 :     return new SwFrmPage( pParent, *rSet );
     827             : }
     828             : 
     829           0 : void SwFrmPage::EnableGraficMode( void )
     830             : {
     831             :     // i#39692 - mustn't be called more than once
     832           0 :     if(!m_pRealSizeBT->IsVisible())
     833             :     {
     834           0 :         m_pWidthFT->Show();
     835           0 :         m_pWidthAutoFT->Hide();
     836           0 :         m_pAutoHeightCB->Hide();
     837             : 
     838           0 :         m_pHeightFT->Show();
     839           0 :         m_pHeightAutoFT->Hide();
     840           0 :         m_pAutoWidthCB->Hide();
     841             : 
     842           0 :         m_pRealSizeBT->Show();
     843             :     }
     844           0 : }
     845             : 
     846           0 : SwWrtShell *SwFrmPage::getFrmDlgParentShell()
     847             : {
     848           0 :     return ((SwFrmDlg*)GetParentDialog())->GetWrtShell();
     849             : }
     850             : 
     851           0 : void SwFrmPage::Reset( const SfxItemSet *rSet )
     852             : {
     853             :     SwWrtShell* pSh = bFormat ? ::GetActiveWrtShell() :
     854           0 :             getFrmDlgParentShell();
     855             : 
     856           0 :     nHtmlMode = ::GetHtmlMode(pSh->GetView().GetDocShell());
     857           0 :     bHtmlMode = nHtmlMode & HTMLMODE_ON ? sal_True : sal_False;
     858             : 
     859           0 :     FieldUnit aMetric = ::GetDfltMetric(bHtmlMode);
     860           0 :     m_aWidthED.SetMetric(aMetric);
     861           0 :     m_aHeightED.SetMetric(aMetric);
     862           0 :     SetMetric( *m_pAtHorzPosED, aMetric );
     863           0 :     SetMetric( *m_pAtVertPosED, aMetric );
     864             : 
     865           0 :     const SfxPoolItem* pItem = NULL;
     866           0 :     const SwFmtAnchor& rAnchor = (const SwFmtAnchor&)rSet->Get(RES_ANCHOR);
     867             : 
     868           0 :     if (SfxItemState::SET == rSet->GetItemState(FN_OLE_IS_MATH, false, &pItem))
     869           0 :         m_bIsMathOLE = ((const SfxBoolItem*)pItem)->GetValue();
     870           0 :     if (SfxItemState::SET == rSet->GetItemState(FN_MATH_BASELINE_ALIGNMENT, false, &pItem))
     871           0 :         m_bIsMathBaselineAlignment = ((const SfxBoolItem*)pItem)->GetValue();
     872           0 :     EnableVerticalPositioning( !(m_bIsMathOLE && m_bIsMathBaselineAlignment
     873           0 :             && FLY_AS_CHAR == rAnchor.GetAnchorId()) );
     874             : 
     875           0 :     if (bFormat)
     876             :     {
     877             :         // at formats no anchor editing
     878           0 :         m_pAnchorFrame->Enable(false);
     879           0 :         m_pFixedRatioCB->Enable(false);
     880             :     }
     881             :     else
     882             :     {
     883           0 :         if (rAnchor.GetAnchorId() != FLY_AT_FLY && !pSh->IsFlyInFly())
     884           0 :             m_pAnchorAtFrameRB->Hide();
     885             :         // --> OD 2009-08-31 #mongolianlayout#
     886             : //        if ( !bVerticalChanged && pSh->IsFrmVertical(sal_True, bIsInRightToLeft) )
     887           0 :         if ( pSh->IsFrmVertical( true, bIsInRightToLeft, bIsVerticalL2R ) )
     888             :         {
     889           0 :             OUString sHLabel = m_pHorizontalFT->GetText();
     890           0 :             m_pHorizontalFT->SetText(m_pVerticalFT->GetText());
     891           0 :             m_pVerticalFT->SetText(sHLabel);
     892           0 :             bIsVerticalFrame = true;
     893             :         }
     894             :     }
     895             : 
     896           0 :     if ( sDlgType == "PictureDialog" || sDlgType == "ObjectDialog" )
     897             :     {
     898             :         OSL_ENSURE(pSh , "shell not found");
     899             :         //OS: only for the variant Insert/Graphic/Properties
     900           0 :         if(SfxItemState::SET == rSet->GetItemState(FN_PARAM_GRF_REALSIZE, false, &pItem))
     901           0 :             aGrfSize = ((const SvxSizeItem*)pItem)->GetSize();
     902             :         else
     903           0 :             pSh->GetGrfSize( aGrfSize );
     904             : 
     905           0 :         if ( !bNew )
     906             :         {
     907           0 :             m_pRealSizeBT->SetClickHdl(LINK(this, SwFrmPage, RealSizeHdl));
     908           0 :             EnableGraficMode();
     909             :         }
     910             : 
     911           0 :         if ( sDlgType == "PictureDialog" )
     912           0 :             m_pFixedRatioCB->Check( false );
     913             :         else
     914             :         {
     915           0 :             if ( bNew )
     916           0 :                 SetText( SW_RESSTR(STR_OLE_INSERT));
     917             :             else
     918           0 :                 SetText( SW_RESSTR(STR_OLE_EDIT));
     919             :         }
     920             :     }
     921             :     else
     922             :     {
     923           0 :         aGrfSize = ((const SwFmtFrmSize&)rSet->Get(RES_FRM_SIZE)).GetSize();
     924             :     }
     925             : 
     926             :     // entering procent value made possible
     927           0 :     m_aWidthED.SetBaseValue( m_aWidthED.Normalize(aGrfSize.Width()), FUNIT_TWIP );
     928           0 :     m_aHeightED.SetBaseValue( m_aHeightED.Normalize(aGrfSize.Height()), FUNIT_TWIP );
     929             :     //the available space is not yet known so the RefValue has to be calculated from size and relative size values
     930             :     //this is needed only if relative values are already set
     931             : 
     932           0 :     const SwFmtFrmSize& rFrmSize = (const SwFmtFrmSize&)rSet->Get(RES_FRM_SIZE);
     933             : 
     934           0 :     m_pRelWidthRelationLB->InsertEntry(aFramePosString.GetString(SwFPos::FRAME));
     935           0 :     m_pRelWidthRelationLB->InsertEntry(aFramePosString.GetString(SwFPos::REL_PG_FRAME));
     936           0 :     if (rFrmSize.GetWidthPercent() != 0xff && rFrmSize.GetWidthPercent() != 0)
     937             :     {
     938             :         //calculate the rerference value from the with and relative width values
     939           0 :         sal_Int32 nSpace = rFrmSize.GetWidth() * 100 / rFrmSize.GetWidthPercent();
     940           0 :         m_aWidthED.SetRefValue( nSpace );
     941             : 
     942           0 :         m_pRelWidthRelationLB->Enable();
     943             :     }
     944             :     else
     945           0 :         m_pRelWidthRelationLB->Disable();
     946             : 
     947           0 :     m_pRelHeightRelationLB->InsertEntry(aFramePosString.GetString(SwFPos::FRAME));
     948           0 :     m_pRelHeightRelationLB->InsertEntry(aFramePosString.GetString(SwFPos::REL_PG_FRAME));
     949           0 :     if (rFrmSize.GetHeightPercent() != 0xff && rFrmSize.GetHeightPercent() != 0)
     950             :     {
     951             :         //calculate the rerference value from the with and relative width values
     952           0 :         sal_Int32 nSpace = rFrmSize.GetHeight() * 100 / rFrmSize.GetHeightPercent();
     953           0 :         m_aHeightED.SetRefValue( nSpace );
     954             : 
     955           0 :         m_pRelHeightRelationLB->Enable();
     956             :     }
     957             :     else
     958           0 :         m_pRelHeightRelationLB->Disable();
     959             : 
     960             :     // general initialisation part
     961           0 :     switch(rAnchor.GetAnchorId())
     962             :     {
     963           0 :         case FLY_AT_PAGE: m_pAnchorAtPageRB->Check(); break;
     964           0 :         case FLY_AT_PARA: m_pAnchorAtParaRB->Check(); break;
     965           0 :         case FLY_AT_CHAR: m_pAnchorAtCharRB->Check(); break;
     966           0 :         case FLY_AS_CHAR: m_pAnchorAsCharRB->Check(); break;
     967           0 :         case FLY_AT_FLY: m_pAnchorAtFrameRB->Check();break;
     968             :         default:; //prevent warning
     969             :     }
     970             : 
     971             :     // i#22341 - determine content position of character
     972             :     // Note: content position can be NULL
     973           0 :     mpToCharCntntPos = rAnchor.GetCntntAnchor();
     974             : 
     975             :     // i#18732 - init checkbox value
     976             :     {
     977             :         const bool bFollowTextFlow =
     978           0 :             static_cast<const SwFmtFollowTextFlow&>(rSet->Get(RES_FOLLOW_TEXT_FLOW)).GetValue();
     979           0 :         m_pFollowTextFlowCB->Check( bFollowTextFlow );
     980             :     }
     981             : 
     982           0 :     if(bHtmlMode)
     983             :     {
     984           0 :         m_pAutoHeightCB->Enable(false);
     985           0 :         m_pAutoWidthCB->Enable(false);
     986           0 :         m_pMirrorPagesCB->Show(false);
     987           0 :         if (sDlgType == "FrameDialog")
     988           0 :             m_pFixedRatioCB->Enable(false);
     989             :         // i#18732 hide checkbox in HTML mode
     990           0 :         m_pFollowTextFlowCB->Show(false);
     991             :     }
     992             :     else
     993             :     {
     994             :         // enable/disable of check box 'Mirror on..'
     995           0 :         m_pMirrorPagesCB->Enable(!m_pAnchorAsCharRB->IsChecked());
     996             : 
     997             :         // enable/disable check box 'Follow text flow'.
     998             :         // enable check box 'Follow text
     999             :         // flow' also for anchor type to-frame.
    1000           0 :         m_pFollowTextFlowCB->Enable( m_pAnchorAtParaRB->IsChecked() ||
    1001           0 :                                   m_pAnchorAtCharRB->IsChecked() ||
    1002           0 :                                   m_pAnchorAtFrameRB->IsChecked() );
    1003             :     }
    1004             : 
    1005           0 :     Init( *rSet, true );
    1006           0 :     m_pAtVertPosED->SaveValue();
    1007           0 :     m_pAtHorzPosED->SaveValue();
    1008           0 :     m_pFollowTextFlowCB->SaveValue();
    1009             : 
    1010           0 :     bNoModifyHdl = false;
    1011             :     //lock PercentFields
    1012           0 :     m_aWidthED.LockAutoCalculation(true);
    1013           0 :     m_aHeightED.LockAutoCalculation(true);
    1014           0 :     RangeModifyHdl(&m_aWidthED);  // set all maximum values initially
    1015           0 :     m_aHeightED.LockAutoCalculation(false);
    1016           0 :     m_aWidthED.LockAutoCalculation(false);
    1017             : 
    1018           0 :     m_pAutoHeightCB->SaveValue();
    1019           0 :     m_pAutoWidthCB->SaveValue();
    1020             : 
    1021           0 :     SwTwips nWidth  = static_cast< SwTwips >(m_aWidthED.DenormalizePercent(m_aWidthED.GetValue(FUNIT_TWIP)));
    1022           0 :     SwTwips nHeight = static_cast< SwTwips >(m_aHeightED.DenormalizePercent(m_aHeightED.GetValue(FUNIT_TWIP)));
    1023           0 :     fWidthHeightRatio = nHeight ? double(nWidth) / double(nHeight) : 1.0;
    1024           0 : }
    1025             : 
    1026             : // stuff attributes into the set when OK
    1027           0 : bool SwFrmPage::FillItemSet(SfxItemSet *rSet)
    1028             : {
    1029           0 :     bool bRet = false;
    1030             :     SwWrtShell* pSh = bFormat ? ::GetActiveWrtShell()
    1031           0 :                         : getFrmDlgParentShell();
    1032             :     OSL_ENSURE( pSh , "shell not found");
    1033           0 :     const SfxItemSet& rOldSet = GetItemSet();
    1034           0 :     const SfxPoolItem* pOldItem = 0;
    1035             : 
    1036           0 :     RndStdIds eAnchorId = (RndStdIds)GetAnchor();
    1037             : 
    1038           0 :     if ( !bFormat )
    1039             :     {
    1040           0 :         pOldItem = GetOldItem(*rSet, RES_ANCHOR);
    1041           0 :         if (bNew || !pOldItem || eAnchorId != ((const SwFmtAnchor*)pOldItem)->GetAnchorId())
    1042             :         {
    1043           0 :             SwFmtAnchor aAnc( eAnchorId, pSh->GetPhyPageNum() );
    1044           0 :             bRet = 0 != rSet->Put( aAnc );
    1045             :         }
    1046             :     }
    1047             : 
    1048           0 :     if ( pHMap )
    1049             :     {
    1050             :         SwFmtHoriOrient aHoriOrient( (const SwFmtHoriOrient&)
    1051           0 :                                                 rOldSet.Get(RES_HORI_ORIENT) );
    1052             : 
    1053           0 :         const sal_Int32 nMapPos = GetMapPos(pHMap, *m_pHorizontalDLB);
    1054           0 :         const sal_Int16 eHOri = GetAlignment(pHMap, nMapPos, *m_pHorizontalDLB, *m_pHoriRelationLB);
    1055           0 :         const sal_Int16 eRel = GetRelation(pHMap, *m_pHoriRelationLB);
    1056             : 
    1057           0 :         aHoriOrient.SetHoriOrient( eHOri );
    1058           0 :         aHoriOrient.SetRelationOrient( eRel );
    1059           0 :         aHoriOrient.SetPosToggle(m_pMirrorPagesCB->IsChecked());
    1060             : 
    1061           0 :         bool bMod = m_pAtHorzPosED->IsValueChangedFromSaved();
    1062           0 :         bMod |= m_pMirrorPagesCB->IsValueChangedFromSaved();
    1063             : 
    1064           0 :         if ( eHOri == text::HoriOrientation::NONE &&
    1065           0 :              (bNew || (bAtHorzPosModified || bMod) || nOldH != eHOri ) )
    1066             :         {
    1067           0 :             SwTwips nX = static_cast< SwTwips >(m_pAtHorzPosED->Denormalize(m_pAtHorzPosED->GetValue(FUNIT_TWIP)));
    1068           0 :             aHoriOrient.SetPos( nX );
    1069             :         }
    1070             : 
    1071           0 :         pOldItem = GetOldItem(*rSet, FN_HORI_ORIENT);
    1072           0 :         bool bSame = false;
    1073           0 :         if ((bNew == bFormat) && pOldItem)
    1074             :         {
    1075           0 :              bSame = aHoriOrient == (SwFmtHoriOrient&)*pOldItem;
    1076             :         }
    1077           0 :         if ((bNew && !bFormat) || ((bAtHorzPosModified || bMod) && !bSame))
    1078             :         {
    1079           0 :             bRet |= 0 != rSet->Put( aHoriOrient );
    1080           0 :         }
    1081             :     }
    1082             : 
    1083           0 :     if ( pVMap )
    1084             :     {
    1085             :         // alignment vertical
    1086             :         SwFmtVertOrient aVertOrient( (const SwFmtVertOrient&)
    1087           0 :                                                 rOldSet.Get(RES_VERT_ORIENT) );
    1088             : 
    1089           0 :         const sal_Int32 nMapPos = GetMapPos(pVMap, *m_pVerticalDLB);
    1090           0 :         const sal_Int16 eVOri = GetAlignment(pVMap, nMapPos, *m_pVerticalDLB, *m_pVertRelationLB);
    1091           0 :         const sal_Int16 eRel = GetRelation(pVMap, *m_pVertRelationLB);
    1092             : 
    1093           0 :         aVertOrient.SetVertOrient    ( eVOri);
    1094           0 :         aVertOrient.SetRelationOrient( eRel );
    1095             : 
    1096           0 :         bool bMod = m_pAtVertPosED->IsValueChangedFromSaved();
    1097             : 
    1098           0 :         if ( eVOri == text::VertOrientation::NONE &&
    1099           0 :              ( bNew || (bAtVertPosModified || bMod) || nOldV != eVOri) )
    1100             :         {
    1101             :             // vertival position
    1102             :             // recalculate offset for character bound frames
    1103           0 :             SwTwips nY = static_cast< SwTwips >(m_pAtVertPosED->Denormalize(m_pAtVertPosED->GetValue(FUNIT_TWIP)));
    1104           0 :             if (eAnchorId == FLY_AS_CHAR)
    1105             :             {
    1106           0 :                 nY *= -1;
    1107             :             }
    1108           0 :             aVertOrient.SetPos( nY );
    1109             :         }
    1110           0 :         pOldItem = GetOldItem(*rSet, FN_VERT_ORIENT);
    1111           0 :         bool bSame = false;
    1112           0 :         if((bNew == bFormat) && pOldItem)
    1113             :         {
    1114             :              bSame = bFormat ?
    1115           0 :                       aVertOrient.GetVertOrient() == ((SwFmtVertOrient*)pOldItem)->GetVertOrient() &&
    1116           0 :                       aVertOrient.GetRelationOrient() == ((SwFmtVertOrient*)pOldItem)->GetRelationOrient() &&
    1117           0 :                       aVertOrient.GetPos() == ((SwFmtVertOrient*)pOldItem)->GetPos()
    1118           0 :                     : aVertOrient == (SwFmtVertOrient&)*pOldItem;
    1119             :         }
    1120           0 :         if( ( bNew && !bFormat ) || ((bAtVertPosModified || bMod) && !bSame ))
    1121             :         {
    1122           0 :             bRet |= 0 != rSet->Put( aVertOrient );
    1123           0 :         }
    1124             :     }
    1125             : 
    1126             :     // set size
    1127             :     // new exception: when the size of pMgr(, 0), then the properties
    1128             :     // for a graphic that isn't even loaded, are set. Then no SetSize
    1129             :     // is done here when the size settings were not changed by the
    1130             :     // user.
    1131           0 :     const SwFmtFrmSize& rOldSize = (const SwFmtFrmSize& )rOldSet.Get(RES_FRM_SIZE);
    1132           0 :     SwFmtFrmSize aSz( rOldSize );
    1133             : 
    1134           0 :     sal_Int32 nRelWidthRelation = m_pRelWidthRelationLB->GetSelectEntryPos();
    1135           0 :     if (nRelWidthRelation != LISTBOX_ENTRY_NOTFOUND)
    1136             :     {
    1137           0 :         if (nRelWidthRelation == 0)
    1138           0 :             aSz.SetWidthPercentRelation(text::RelOrientation::FRAME);
    1139           0 :         else if (nRelWidthRelation == 1)
    1140           0 :             aSz.SetWidthPercentRelation(text::RelOrientation::PAGE_FRAME);
    1141             :     }
    1142           0 :     sal_Int32 nRelHeightRelation = m_pRelHeightRelationLB->GetSelectEntryPos();
    1143           0 :     if (nRelHeightRelation != LISTBOX_ENTRY_NOTFOUND)
    1144             :     {
    1145           0 :         if (nRelHeightRelation == 0)
    1146           0 :             aSz.SetHeightPercentRelation(text::RelOrientation::FRAME);
    1147           0 :         else if (nRelHeightRelation == 1)
    1148           0 :             aSz.SetHeightPercentRelation(text::RelOrientation::PAGE_FRAME);
    1149             :     }
    1150             : 
    1151           0 :     bool bValueModified = (m_aWidthED.IsValueModified() || m_aHeightED.IsValueModified());
    1152           0 :     bool bCheckChanged = m_pRelWidthCB->IsValueChangedFromSaved()
    1153           0 :                          || m_pRelHeightCB->IsValueChangedFromSaved();
    1154             : 
    1155           0 :     bool bLegalValue = !(!rOldSize.GetWidth () && !rOldSize.GetHeight() &&
    1156           0 :                             m_aWidthED .GetValue() == m_aWidthED .GetMin() &&
    1157           0 :                             m_aHeightED.GetValue() == m_aHeightED.GetMin());
    1158             : 
    1159           0 :     if ((bNew && !bFormat) || ((bValueModified || bCheckChanged) && bLegalValue))
    1160             :     {
    1161           0 :         sal_Int64 nNewWidth  = m_aWidthED.DenormalizePercent(m_aWidthED.GetRealValue(FUNIT_TWIP));
    1162           0 :         sal_Int64 nNewHeight = m_aHeightED.DenormalizePercent(m_aHeightED.GetRealValue(FUNIT_TWIP));
    1163           0 :         aSz.SetWidth (static_cast< SwTwips >(nNewWidth));
    1164           0 :         aSz.SetHeight(static_cast< SwTwips >(nNewHeight));
    1165             : 
    1166           0 :         if (m_pRelWidthCB->IsChecked())
    1167             :         {
    1168           0 :             aSz.SetWidthPercent((sal_uInt8)std::min( static_cast< sal_Int64 >(MAX_PERCENT_WIDTH), m_aWidthED.Convert(m_aWidthED.NormalizePercent(nNewWidth), FUNIT_TWIP, FUNIT_CUSTOM)));
    1169             :         }
    1170             :         else
    1171           0 :             aSz.SetWidthPercent(0);
    1172           0 :         if (m_pRelHeightCB->IsChecked())
    1173           0 :             aSz.SetHeightPercent((sal_uInt8)std::min(static_cast< sal_Int64 >(MAX_PERCENT_HEIGHT), m_aHeightED.Convert(m_aHeightED.NormalizePercent(nNewHeight), FUNIT_TWIP, FUNIT_CUSTOM)));
    1174             :         else
    1175           0 :             aSz.SetHeightPercent(0);
    1176             : 
    1177           0 :         if (m_pFixedRatioCB->IsChecked() && (m_pRelWidthCB->IsChecked() != m_pRelHeightCB->IsChecked()))
    1178             :         {
    1179           0 :             if (m_pRelWidthCB->IsChecked())
    1180           0 :                 aSz.SetHeightPercent(0xff);
    1181             :             else
    1182           0 :                 aSz.SetWidthPercent(0xff);
    1183             :         }
    1184             :     }
    1185           0 :     if( !IsInGraficMode() )
    1186             :     {
    1187           0 :         if( m_pAutoHeightCB->IsValueChangedFromSaved() )
    1188             :         {
    1189           0 :             SwFrmSize eFrmSize = m_pAutoHeightCB->IsChecked()? ATT_MIN_SIZE : ATT_FIX_SIZE;
    1190           0 :             if( eFrmSize != aSz.GetHeightSizeType() )
    1191           0 :                 aSz.SetHeightSizeType(eFrmSize);
    1192             :         }
    1193           0 :         if( m_pAutoWidthCB->IsValueChangedFromSaved() )
    1194             :         {
    1195           0 :             SwFrmSize eFrmSize = m_pAutoWidthCB->IsChecked()? ATT_MIN_SIZE : ATT_FIX_SIZE;
    1196           0 :             if( eFrmSize != aSz.GetWidthSizeType() )
    1197           0 :                 aSz.SetWidthSizeType( eFrmSize );
    1198             :         }
    1199             :     }
    1200           0 :     if( !bFormat && m_pFixedRatioCB->IsValueChangedFromSaved() )
    1201           0 :         bRet |= 0 != rSet->Put(SfxBoolItem(FN_KEEP_ASPECT_RATIO, m_pFixedRatioCB->IsChecked()));
    1202             : 
    1203           0 :     pOldItem = GetOldItem(*rSet, RES_FRM_SIZE);
    1204             : 
    1205           0 :     if ((pOldItem && aSz != *pOldItem) || (!pOldItem && !bFormat) ||
    1206           0 :             (bFormat &&
    1207           0 :                 (aSz.GetWidth() > 0 || aSz.GetWidthPercent() > 0) &&
    1208           0 :                     (aSz.GetHeight() > 0 || aSz.GetHeightPercent() > 0)))
    1209             :     {
    1210           0 :         if (aSz.GetHeightSizeType() == ATT_VAR_SIZE)    // there is no VAR_SIZE in frames
    1211           0 :             aSz.SetHeightSizeType(ATT_MIN_SIZE);
    1212             : 
    1213           0 :         bRet |= 0 != rSet->Put( aSz );
    1214             :     }
    1215           0 :     if(m_pFollowTextFlowCB->IsValueChangedFromSaved())
    1216             :     {
    1217           0 :         bRet |= 0 != rSet->Put(SwFmtFollowTextFlow(m_pFollowTextFlowCB->IsChecked()));
    1218             :     }
    1219           0 :     return bRet;
    1220             : }
    1221             : 
    1222             : // initialise horizonal and vertical Pos
    1223           0 : void SwFrmPage::InitPos(RndStdIds eId,
    1224             :                                 sal_Int16 nH,
    1225             :                                 sal_Int16 nHRel,
    1226             :                                 sal_Int16 nV,
    1227             :                                 sal_Int16 nVRel,
    1228             :                                 long   nX,
    1229             :                                 long   nY)
    1230             : {
    1231           0 :     sal_Int32 nPos = m_pVerticalDLB->GetSelectEntryPos();
    1232           0 :     if ( nPos != LISTBOX_ENTRY_NOTFOUND && pVMap )
    1233             :     {
    1234           0 :         nOldV    = pVMap[nPos].nAlign;
    1235             : 
    1236           0 :         nPos = m_pVertRelationLB->GetSelectEntryPos();
    1237           0 :         if (nPos != LISTBOX_ENTRY_NOTFOUND)
    1238           0 :             nOldVRel = ((RelationMap *)m_pVertRelationLB->GetEntryData(nPos))->nRelation;
    1239             :     }
    1240             : 
    1241           0 :     nPos = m_pHorizontalDLB->GetSelectEntryPos();
    1242           0 :     if ( nPos != LISTBOX_ENTRY_NOTFOUND && pHMap )
    1243             :     {
    1244           0 :         nOldH    = pHMap[nPos].nAlign;
    1245             : 
    1246           0 :         nPos = m_pHoriRelationLB->GetSelectEntryPos();
    1247           0 :         if (nPos != LISTBOX_ENTRY_NOTFOUND)
    1248           0 :             nOldHRel = ((RelationMap *)m_pHoriRelationLB->GetEntryData(nPos))->nRelation;
    1249             :     }
    1250             : 
    1251           0 :     bool bEnable = true;
    1252           0 :     if ( eId == FLY_AT_PAGE )
    1253             :     {
    1254           0 :         pVMap = bHtmlMode ? aVPageHtmlMap : aVPageMap;
    1255           0 :         pHMap = bHtmlMode ? aHPageHtmlMap : aHPageMap;
    1256             :     }
    1257           0 :     else if ( eId == FLY_AT_FLY )
    1258             :     {
    1259             :         // own vertical alignment map for to frame
    1260             :         // anchored objects.
    1261           0 :         pVMap = bHtmlMode ? aVFlyHtmlMap : aVFrameMap;
    1262           0 :         pHMap = bHtmlMode ? aHFlyHtmlMap : aHFrameMap;
    1263             :     }
    1264           0 :     else if ( eId == FLY_AT_PARA )
    1265             :     {
    1266           0 :         if(bHtmlMode)
    1267             :         {
    1268           0 :             pVMap = aVParaHtmlMap;
    1269           0 :             pHMap = aHParaHtmlAbsMap;
    1270             :         }
    1271             :         else
    1272             :         {
    1273           0 :             pVMap = aVParaMap;
    1274           0 :             pHMap = aHParaMap;
    1275             :         }
    1276             :     }
    1277           0 :     else if ( eId == FLY_AT_CHAR )
    1278             :     {
    1279           0 :         if(bHtmlMode)
    1280             :         {
    1281           0 :             pVMap = aVCharHtmlAbsMap;
    1282           0 :             pHMap = aHCharHtmlAbsMap;
    1283             :         }
    1284             :         else
    1285             :         {
    1286           0 :             pVMap = aVCharMap;
    1287           0 :             pHMap = aHCharMap;
    1288             :         }
    1289             :     }
    1290           0 :     else if ( eId == FLY_AS_CHAR )
    1291             :     {
    1292           0 :         pVMap = bHtmlMode ? aVAsCharHtmlMap     : aVAsCharMap;
    1293           0 :         pHMap = 0;
    1294           0 :         bEnable = false;
    1295             :     }
    1296           0 :     m_pHorizontalDLB->Enable( bEnable );
    1297           0 :     m_pHorizontalFT->Enable( bEnable );
    1298             : 
    1299             :     // select current Pos
    1300             :     // horizontal
    1301           0 :     if ( nH < 0 )
    1302             :     {
    1303           0 :         nH    = nOldH;
    1304           0 :         nHRel = nOldHRel;
    1305             :     }
    1306           0 :     sal_Int32 nMapPos = FillPosLB(pHMap, nH, nHRel, *m_pHorizontalDLB);
    1307           0 :     FillRelLB(pHMap, nMapPos, nH, nHRel, *m_pHoriRelationLB, *m_pHoriRelationFT);
    1308             : 
    1309             :     // vertical
    1310           0 :     if ( nV < 0 )
    1311             :     {
    1312           0 :         nV    = nOldV;
    1313           0 :         nVRel = nOldVRel;
    1314             :     }
    1315           0 :     nMapPos = FillPosLB(pVMap, nV, nVRel, *m_pVerticalDLB);
    1316           0 :     FillRelLB(pVMap, nMapPos, nV, nVRel, *m_pVertRelationLB, *m_pVertRelationFT);
    1317             : 
    1318           0 :     bEnable = nH == text::HoriOrientation::NONE && eId != FLY_AS_CHAR;
    1319           0 :     if (!bEnable)
    1320             :     {
    1321           0 :         m_pAtHorzPosED->SetValue( 0, FUNIT_TWIP );
    1322           0 :         if (nX != LONG_MAX && bHtmlMode)
    1323           0 :             m_pAtHorzPosED->SetModifyFlag();
    1324             :     }
    1325             :     else
    1326             :     {
    1327           0 :         if (nX != LONG_MAX)
    1328           0 :             m_pAtHorzPosED->SetValue( m_pAtHorzPosED->Normalize(nX), FUNIT_TWIP );
    1329             :     }
    1330           0 :     m_pAtHorzPosFT->Enable( bEnable );
    1331           0 :     m_pAtHorzPosED->Enable( bEnable );
    1332             : 
    1333           0 :     bEnable = nV == text::VertOrientation::NONE;
    1334           0 :     if ( !bEnable )
    1335             :     {
    1336           0 :         m_pAtVertPosED->SetValue( 0, FUNIT_TWIP );
    1337           0 :         if(nY != LONG_MAX && bHtmlMode)
    1338           0 :             m_pAtVertPosED->SetModifyFlag();
    1339             :     }
    1340             :     else
    1341             :     {
    1342           0 :         if ( eId == FLY_AS_CHAR )
    1343             :         {
    1344           0 :             if ( nY == LONG_MAX )
    1345           0 :                 nY = 0;
    1346             :             else
    1347           0 :                 nY *= -1;
    1348             :         }
    1349           0 :         if ( nY != LONG_MAX )
    1350           0 :             m_pAtVertPosED->SetValue( m_pAtVertPosED->Normalize(nY), FUNIT_TWIP );
    1351             :     }
    1352           0 :     m_pAtVertPosFT->Enable( bEnable && m_bAllowVertPositioning );
    1353           0 :     m_pAtVertPosED->Enable( bEnable && m_bAllowVertPositioning );
    1354           0 :     UpdateExample();
    1355           0 : }
    1356             : 
    1357           0 : sal_Int32 SwFrmPage::FillPosLB(const FrmMap* _pMap,
    1358             :                             const sal_Int16 _nAlign,
    1359             :                             const sal_Int16 _nRel,
    1360             :                             ListBox& _rLB )
    1361             : {
    1362           0 :     OUString sSelEntry;
    1363           0 :     const OUString sOldEntry = _rLB.GetSelectEntry();
    1364             : 
    1365           0 :     _rLB.Clear();
    1366             : 
    1367             :     // i#22341 determine all possible listbox relations for
    1368             :     // given relation for map <aVCharMap>
    1369             :     const sal_uLong nLBRelations = (_pMap != aVCharMap)
    1370             :                                ? 0L
    1371           0 :                                : ::lcl_GetLBRelationsForRelations( _nRel );
    1372             : 
    1373             :     // fill Listbox
    1374           0 :     size_t nCount = ::lcl_GetFrmMapCount(_pMap);
    1375           0 :     for (size_t i = 0; _pMap && i < nCount; ++i)
    1376             :     {
    1377             : //      Why not from the left/from inside or from above?
    1378             :         {
    1379           0 :             SvxSwFramePosString::StringId eStrId = m_pMirrorPagesCB->IsChecked() ? _pMap[i].eMirrorStrId : _pMap[i].eStrId;
    1380             :             // --> OD 2009-08-31 #mongolianlayout#
    1381             :             eStrId = lcl_ChangeResIdToVerticalOrRTL( eStrId,
    1382             :                                                      bIsVerticalFrame,
    1383             :                                                      bIsVerticalL2R,
    1384           0 :                                                      bIsInRightToLeft);
    1385           0 :             OUString sEntry(aFramePosString.GetString(eStrId));
    1386           0 :             if (_rLB.GetEntryPos(sEntry) == LISTBOX_ENTRY_NOTFOUND)
    1387             :             {
    1388             :                 // don't insert entries when frames are character bound
    1389           0 :                 _rLB.InsertEntry(sEntry);
    1390             :             }
    1391             :             // i#22341 - add condition to handle map <aVCharMap>
    1392             :             // that is ambigous in the alignment.
    1393           0 :             if ( _pMap[i].nAlign == _nAlign &&
    1394           0 :                  ( !(_pMap == aVCharMap) || _pMap[i].nLBRelations & nLBRelations ) )
    1395             :             {
    1396           0 :                 sSelEntry = sEntry;
    1397           0 :             }
    1398             :         }
    1399             :     }
    1400             : 
    1401           0 :     _rLB.SelectEntry(sSelEntry);
    1402           0 :     if (!_rLB.GetSelectEntryCount())
    1403           0 :         _rLB.SelectEntry(sOldEntry);
    1404             : 
    1405           0 :     if (!_rLB.GetSelectEntryCount())
    1406           0 :         _rLB.SelectEntryPos(0);
    1407             : 
    1408           0 :     PosHdl(&_rLB);
    1409             : 
    1410           0 :     return GetMapPos(_pMap, _rLB);
    1411             : }
    1412             : 
    1413           0 : sal_uLong SwFrmPage::FillRelLB( const FrmMap* _pMap,
    1414             :                             const sal_uInt16 _nLBSelPos,
    1415             :                             const sal_Int16 _nAlign,
    1416             :                             const sal_Int16 _nRel,
    1417             :                             ListBox& _rLB,
    1418             :                             FixedText& _rFT )
    1419             : {
    1420           0 :     OUString sSelEntry;
    1421           0 :     sal_uLong  nLBRelations = 0;
    1422           0 :     size_t nMapCount = ::lcl_GetFrmMapCount(_pMap);
    1423             : 
    1424           0 :     _rLB.Clear();
    1425             : 
    1426           0 :     if (_nLBSelPos < nMapCount)
    1427             :     {
    1428           0 :         if (_pMap == aVAsCharHtmlMap || _pMap == aVAsCharMap)
    1429             :         {
    1430           0 :             const OUString sOldEntry(_rLB.GetSelectEntry());
    1431           0 :             const size_t nRelCount = SAL_N_ELEMENTS(aAsCharRelationMap);
    1432           0 :             SvxSwFramePosString::StringId eStrId = _pMap[_nLBSelPos].eStrId;
    1433             : 
    1434           0 :             for (size_t nMapPos = 0; nMapPos < nMapCount; nMapPos++)
    1435             :             {
    1436           0 :                 if (_pMap[nMapPos].eStrId == eStrId)
    1437             :                 {
    1438           0 :                     nLBRelations = _pMap[nMapPos].nLBRelations;
    1439           0 :                     for (size_t nRelPos = 0; nRelPos < nRelCount; ++nRelPos)
    1440             :                     {
    1441           0 :                         if (nLBRelations & aAsCharRelationMap[nRelPos].nLBRelation)
    1442             :                         {
    1443           0 :                             SvxSwFramePosString::StringId sStrId1 = aAsCharRelationMap[nRelPos].eStrId;
    1444             : 
    1445             :                             // --> OD 2009-08-31 #mongolianlayout#
    1446             :                             sStrId1 =
    1447             :                                 lcl_ChangeResIdToVerticalOrRTL( sStrId1,
    1448             :                                                                 bIsVerticalFrame,
    1449             :                                                                 bIsVerticalL2R,
    1450           0 :                                                                 bIsInRightToLeft);
    1451           0 :                             const OUString sEntry = aFramePosString.GetString(sStrId1);
    1452           0 :                             sal_Int32 nPos = _rLB.InsertEntry(sEntry);
    1453           0 :                             _rLB.SetEntryData(nPos, &aAsCharRelationMap[nRelPos]);
    1454           0 :                             if (_pMap[nMapPos].nAlign == _nAlign)
    1455           0 :                                 sSelEntry = sEntry;
    1456           0 :                             break;
    1457             :                         }
    1458             :                     }
    1459             :                 }
    1460             :             }
    1461           0 :             if (!sSelEntry.isEmpty())
    1462           0 :                 _rLB.SelectEntry(sSelEntry);
    1463             :             else
    1464             :             {
    1465           0 :                 _rLB.SelectEntry(sOldEntry);
    1466             : 
    1467           0 :                 if (!_rLB.GetSelectEntryCount())
    1468             :                 {
    1469           0 :                     for (sal_Int32 i = 0; i < _rLB.GetEntryCount(); i++)
    1470             :                     {
    1471           0 :                         RelationMap *pEntry = (RelationMap *)_rLB.GetEntryData(i);
    1472           0 :                         if (pEntry->nLBRelation == LB_REL_CHAR) // default
    1473             :                         {
    1474           0 :                             _rLB.SelectEntryPos(i);
    1475           0 :                             break;
    1476             :                         }
    1477             :                     }
    1478             :                 }
    1479           0 :             }
    1480             :         }
    1481             :         else
    1482             :         {
    1483             :             // special handling for map <aVCharMap>,
    1484             :             // because its ambigous in its <eStrId>/<eMirrorStrId>.
    1485           0 :             if ( _pMap == aVCharMap )
    1486             :             {
    1487             :                 nLBRelations = ::lcl_GetLBRelationsForStrID( _pMap,
    1488           0 :                                              ( m_pMirrorPagesCB->IsChecked()
    1489           0 :                                                ? _pMap[_nLBSelPos].eMirrorStrId
    1490           0 :                                                : _pMap[_nLBSelPos].eStrId),
    1491           0 :                                              m_pMirrorPagesCB->IsChecked() );
    1492             :             }
    1493             :             else
    1494             :             {
    1495           0 :                 nLBRelations = _pMap[_nLBSelPos].nLBRelations;
    1496             :             }
    1497             : 
    1498           0 :             const size_t nRelCount = SAL_N_ELEMENTS(aRelationMap);
    1499             : 
    1500           0 :             for (sal_uLong nBit = 1; nBit < 0x80000000; nBit <<= 1)
    1501             :             {
    1502           0 :                 if (nLBRelations & nBit)
    1503             :                 {
    1504           0 :                     for (size_t nRelPos = 0; nRelPos < nRelCount; ++nRelPos)
    1505             :                     {
    1506           0 :                         if (aRelationMap[nRelPos].nLBRelation == nBit)
    1507             :                         {
    1508           0 :                             SvxSwFramePosString::StringId eStrId1 = m_pMirrorPagesCB->IsChecked() ?
    1509           0 :                                             aRelationMap[nRelPos].eMirrorStrId : aRelationMap[nRelPos].eStrId;
    1510             :                             // --> OD 2009-08-31 #mongolianlayout#
    1511             :                             eStrId1 =
    1512             :                                 lcl_ChangeResIdToVerticalOrRTL( eStrId1,
    1513             :                                                                 bIsVerticalFrame,
    1514             :                                                                 bIsVerticalL2R,
    1515           0 :                                                                 bIsInRightToLeft);
    1516           0 :                             const OUString sEntry = aFramePosString.GetString(eStrId1);
    1517           0 :                             sal_Int32 nPos = _rLB.InsertEntry(sEntry);
    1518           0 :                             _rLB.SetEntryData(nPos, &aRelationMap[nRelPos]);
    1519           0 :                             if (sSelEntry.isEmpty() && aRelationMap[nRelPos].nRelation == _nRel)
    1520           0 :                                 sSelEntry = sEntry;
    1521             :                         }
    1522             :                     }
    1523             :                 }
    1524             :             }
    1525           0 :             if (!sSelEntry.isEmpty())
    1526           0 :                 _rLB.SelectEntry(sSelEntry);
    1527             :             else
    1528             :             {
    1529             :                 // Probably anchor switch. So look for similar relation
    1530           0 :                 sal_Int16 nSimRel = -1;
    1531           0 :                 switch (_nRel)
    1532             :                 {
    1533             :                     case text::RelOrientation::FRAME:
    1534           0 :                         nSimRel = text::RelOrientation::PAGE_FRAME;
    1535           0 :                         break;
    1536             :                     case text::RelOrientation::PRINT_AREA:
    1537           0 :                         nSimRel = text::RelOrientation::PAGE_PRINT_AREA;
    1538           0 :                         break;
    1539             :                     case text::RelOrientation::PAGE_LEFT:
    1540           0 :                         nSimRel = text::RelOrientation::FRAME_LEFT;
    1541           0 :                         break;
    1542             :                     case text::RelOrientation::PAGE_RIGHT:
    1543           0 :                         nSimRel = text::RelOrientation::FRAME_RIGHT;
    1544           0 :                         break;
    1545             :                     case text::RelOrientation::FRAME_LEFT:
    1546           0 :                         nSimRel = text::RelOrientation::PAGE_LEFT;
    1547           0 :                         break;
    1548             :                     case text::RelOrientation::FRAME_RIGHT:
    1549           0 :                         nSimRel = text::RelOrientation::PAGE_RIGHT;
    1550           0 :                         break;
    1551             :                     case text::RelOrientation::PAGE_FRAME:
    1552           0 :                         nSimRel = text::RelOrientation::FRAME;
    1553           0 :                         break;
    1554             :                     case text::RelOrientation::PAGE_PRINT_AREA:
    1555           0 :                         nSimRel = text::RelOrientation::PRINT_AREA;
    1556           0 :                         break;
    1557             : 
    1558             :                     default:
    1559           0 :                         if (_rLB.GetEntryCount())
    1560             :                         {
    1561           0 :                             RelationMap *pEntry = (RelationMap *)_rLB.GetEntryData(_rLB.GetEntryCount() - 1);
    1562           0 :                             nSimRel = pEntry->nRelation;
    1563             :                         }
    1564           0 :                         break;
    1565             :                 }
    1566             : 
    1567           0 :                 for (sal_Int32 i = 0; i < _rLB.GetEntryCount(); i++)
    1568             :                 {
    1569           0 :                     RelationMap *pEntry = (RelationMap *)_rLB.GetEntryData(i);
    1570           0 :                     if (pEntry->nRelation == nSimRel)
    1571             :                     {
    1572           0 :                         _rLB.SelectEntryPos(i);
    1573           0 :                         break;
    1574             :                     }
    1575             :                 }
    1576             : 
    1577           0 :                 if (!_rLB.GetSelectEntryCount())
    1578           0 :                     _rLB.SelectEntryPos(0);
    1579             :             }
    1580             :         }
    1581             :     }
    1582             : 
    1583           0 :     const bool bEnable = _rLB.GetEntryCount() != 0
    1584           0 :             && (&_rLB != m_pVertRelationLB || m_bAllowVertPositioning);
    1585           0 :     _rLB.Enable( bEnable );
    1586           0 :     _rFT.Enable( bEnable );
    1587             : 
    1588           0 :     RelHdl(&_rLB);
    1589             : 
    1590           0 :     return nLBRelations;
    1591             : }
    1592             : 
    1593           0 : sal_Int16 SwFrmPage::GetRelation(FrmMap * /*pMap*/, ListBox &rRelationLB)
    1594             : {
    1595           0 :     const sal_Int32 nPos = rRelationLB.GetSelectEntryPos();
    1596             : 
    1597           0 :     if (nPos != LISTBOX_ENTRY_NOTFOUND)
    1598             :     {
    1599           0 :         RelationMap *pEntry = (RelationMap *)rRelationLB.GetEntryData(nPos);
    1600           0 :         return pEntry->nRelation;
    1601             :     }
    1602             : 
    1603           0 :     return 0;
    1604             : }
    1605             : 
    1606           0 : sal_Int16 SwFrmPage::GetAlignment(FrmMap *pMap, sal_Int32 nMapPos,
    1607             :         ListBox &/*rAlignLB*/, ListBox &rRelationLB)
    1608             : {
    1609           0 :     if (!pMap || nMapPos < 0)
    1610           0 :         return 0;
    1611             : 
    1612           0 :     const size_t nMapCount = ::lcl_GetFrmMapCount(pMap);
    1613             : 
    1614           0 :     if (static_cast<size_t>(nMapPos) >= nMapCount)
    1615           0 :         return 0;
    1616             : 
    1617             :     // i#22341 special handling also for map <aVCharMap>,
    1618             :     // because it contains ambigous items for alignment
    1619           0 :     if ( pMap != aVAsCharHtmlMap && pMap != aVAsCharMap && pMap != aVCharMap )
    1620           0 :         return pMap[nMapPos].nAlign;
    1621             : 
    1622           0 :     if (rRelationLB.GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND)
    1623           0 :         return 0;
    1624             : 
    1625             :     const RelationMap *const pRelationMap = (const RelationMap *const )
    1626           0 :         rRelationLB.GetEntryData(rRelationLB.GetSelectEntryPos());
    1627           0 :     const sal_uLong nRel = pRelationMap->nLBRelation;
    1628           0 :     const SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId;
    1629             : 
    1630           0 :     for (size_t i = 0; i < nMapCount; ++i)
    1631             :     {
    1632           0 :         if (pMap[i].eStrId == eStrId && (pMap[i].nLBRelations & nRel))
    1633           0 :             return pMap[i].nAlign;
    1634             :     }
    1635             : 
    1636           0 :     return 0;
    1637             : }
    1638             : 
    1639           0 : sal_Int32 SwFrmPage::GetMapPos( const FrmMap *pMap, ListBox &rAlignLB )
    1640             : {
    1641           0 :     sal_Int32 nMapPos = 0;
    1642           0 :     sal_Int32 nLBSelPos = rAlignLB.GetSelectEntryPos();
    1643             : 
    1644           0 :     if (nLBSelPos != LISTBOX_ENTRY_NOTFOUND)
    1645             :     {
    1646           0 :         if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap)
    1647             :         {
    1648           0 :             const size_t nMapCount = ::lcl_GetFrmMapCount(pMap);
    1649           0 :             const OUString sSelEntry(rAlignLB.GetSelectEntry());
    1650             : 
    1651           0 :             for (size_t i = 0; i < nMapCount; i++)
    1652             :             {
    1653           0 :                 SvxSwFramePosString::StringId eResId = pMap[i].eStrId;
    1654             : 
    1655           0 :                 OUString sEntry = aFramePosString.GetString(eResId);
    1656           0 :                 sEntry = MnemonicGenerator::EraseAllMnemonicChars( sEntry );
    1657             : 
    1658           0 :                 if (sEntry == sSelEntry)
    1659             :                 {
    1660           0 :                     nMapPos = static_cast< sal_Int32 >(i);
    1661           0 :                     break;
    1662             :                 }
    1663           0 :             }
    1664             :         }
    1665             :         else
    1666           0 :             nMapPos = nLBSelPos;
    1667             :     }
    1668             : 
    1669           0 :     return nMapPos;
    1670             : }
    1671             : 
    1672           0 : RndStdIds SwFrmPage::GetAnchor()
    1673             : {
    1674           0 :     RndStdIds nRet = FLY_AT_PAGE;
    1675           0 :     if(m_pAnchorAtParaRB->IsChecked())
    1676             :     {
    1677           0 :         nRet = FLY_AT_PARA;
    1678             :     }
    1679           0 :     else if(m_pAnchorAtCharRB->IsChecked())
    1680             :     {
    1681           0 :         nRet = FLY_AT_CHAR;
    1682             :     }
    1683           0 :     else if(m_pAnchorAsCharRB->IsChecked())
    1684             :     {
    1685           0 :         nRet = FLY_AS_CHAR;
    1686             :     }
    1687           0 :     else if(m_pAnchorAtFrameRB->IsChecked())
    1688             :     {
    1689           0 :         nRet = FLY_AT_FLY;
    1690             :     }
    1691           0 :     return nRet;
    1692             : }
    1693             : 
    1694             : // Bsp - Update
    1695           0 : void SwFrmPage::ActivatePage(const SfxItemSet& rSet)
    1696             : {
    1697           0 :     bNoModifyHdl = true;
    1698           0 :     Init(rSet);
    1699           0 :     bNoModifyHdl = false;
    1700             :     //lock PercentFields
    1701           0 :     m_aWidthED.LockAutoCalculation(true);
    1702           0 :     m_aHeightED.LockAutoCalculation(true);
    1703           0 :     RangeModifyHdl(&m_aWidthED);  // set all maximum values initially
    1704           0 :     m_aHeightED.LockAutoCalculation(false);
    1705           0 :     m_aWidthED.LockAutoCalculation(false);
    1706           0 :     m_pFollowTextFlowCB->SaveValue();
    1707           0 : }
    1708             : 
    1709           0 : int SwFrmPage::DeactivatePage(SfxItemSet * _pSet)
    1710             : {
    1711           0 :     if ( _pSet )
    1712             :     {
    1713           0 :         FillItemSet( _pSet );
    1714             : 
    1715             :         //FillItemSet doesn't set the anchor into the set when it matches
    1716             :         //the original. But for the other pages we need the current anchor.
    1717             :         SwWrtShell* pSh = bFormat ? ::GetActiveWrtShell()
    1718           0 :                             : getFrmDlgParentShell();
    1719           0 :         RndStdIds eAnchorId = (RndStdIds)GetAnchor();
    1720           0 :         SwFmtAnchor aAnc( eAnchorId, pSh->GetPhyPageNum() );
    1721           0 :         _pSet->Put( aAnc );
    1722             :     }
    1723             : 
    1724           0 :     return sal_True;
    1725             : }
    1726             : 
    1727             : // swap left/right with inside/outside
    1728           0 : IMPL_LINK_NOARG(SwFrmPage, MirrorHdl)
    1729             : {
    1730           0 :     RndStdIds eId = GetAnchor();
    1731           0 :     InitPos( eId, -1, 0, -1, 0, LONG_MAX, LONG_MAX);
    1732             : 
    1733           0 :     return 0;
    1734             : }
    1735             : 
    1736           0 : IMPL_LINK( SwFrmPage, RelSizeClickHdl, CheckBox *, pBtn )
    1737             : {
    1738           0 :     if (pBtn == m_pRelWidthCB)
    1739             :     {
    1740           0 :         m_aWidthED.ShowPercent(pBtn->IsChecked());
    1741           0 :         m_pRelWidthRelationLB->Enable(pBtn->IsChecked());
    1742           0 :         if(pBtn->IsChecked())
    1743           0 :             m_aWidthED.get()->SetMax(MAX_PERCENT_WIDTH);
    1744             :     }
    1745             :     else // pBtn == m_pRelHeightCB
    1746             :     {
    1747           0 :         m_aHeightED.ShowPercent(pBtn->IsChecked());
    1748           0 :         m_pRelHeightRelationLB->Enable(pBtn->IsChecked());
    1749           0 :         if(pBtn->IsChecked())
    1750           0 :             m_aHeightED.get()->SetMax(MAX_PERCENT_HEIGHT);
    1751             :     }
    1752             : 
    1753           0 :     RangeModifyHdl(m_aWidthED.get());  // correct the values again
    1754             : 
    1755           0 :     if (pBtn == m_pRelWidthCB)
    1756           0 :         ModifyHdl(m_aWidthED.get());
    1757             :     else // pBtn == m_pRelHeightCB
    1758           0 :         ModifyHdl(m_aHeightED.get());
    1759             : 
    1760           0 :     return 0;
    1761             : }
    1762             : 
    1763             : // range check
    1764           0 : IMPL_LINK_NOARG(SwFrmPage, RangeModifyHdl)
    1765             : {
    1766           0 :     if (bNoModifyHdl)
    1767           0 :         return 0;
    1768             : 
    1769             :     SwWrtShell* pSh = bFormat ? ::GetActiveWrtShell()
    1770           0 :                         : getFrmDlgParentShell();
    1771             :     OSL_ENSURE(pSh , "shell not found");
    1772           0 :     SwFlyFrmAttrMgr aMgr( bNew, pSh, (const SwAttrSet&)GetItemSet() );
    1773           0 :     SvxSwFrameValidation        aVal;
    1774             : 
    1775           0 :     aVal.nAnchorType = static_cast< sal_Int16 >(GetAnchor());
    1776           0 :     aVal.bAutoHeight = m_pAutoHeightCB->IsChecked();
    1777           0 :     aVal.bAutoWidth = m_pAutoWidthCB->IsChecked();
    1778           0 :     aVal.bMirror = m_pMirrorPagesCB->IsChecked();
    1779           0 :     aVal.bFollowTextFlow = m_pFollowTextFlowCB->IsChecked();
    1780             : 
    1781           0 :     if ( pHMap )
    1782             :     {
    1783             :         // alignment horizonal
    1784           0 :         const sal_Int32 nMapPos = GetMapPos(pHMap, *m_pHorizontalDLB);
    1785           0 :         aVal.nHoriOrient = GetAlignment(pHMap, nMapPos, *m_pHorizontalDLB, *m_pHoriRelationLB);
    1786           0 :         aVal.nHRelOrient = GetRelation(pHMap, *m_pHoriRelationLB);
    1787             :     }
    1788             :     else
    1789           0 :         aVal.nHoriOrient = text::HoriOrientation::NONE;
    1790             : 
    1791           0 :     if ( pVMap )
    1792             :     {
    1793             :         // alignment vertical
    1794           0 :         const sal_Int32 nMapPos = GetMapPos(pVMap, *m_pVerticalDLB);
    1795           0 :         aVal.nVertOrient = GetAlignment(pVMap, nMapPos, *m_pVerticalDLB, *m_pVertRelationLB);
    1796           0 :         aVal.nVRelOrient = GetRelation(pVMap, *m_pVertRelationLB);
    1797             :     }
    1798             :     else
    1799           0 :         aVal.nVertOrient = text::VertOrientation::NONE;
    1800             : 
    1801             :     const long nAtHorzPosVal = static_cast< long >(
    1802           0 :                     m_pAtHorzPosED->Denormalize(m_pAtHorzPosED->GetValue(FUNIT_TWIP)) );
    1803             :     const long nAtVertPosVal = static_cast< long >(
    1804           0 :                     m_pAtVertPosED->Denormalize(m_pAtVertPosED->GetValue(FUNIT_TWIP)) );
    1805             : 
    1806           0 :     aVal.nHPos = nAtHorzPosVal;
    1807           0 :     aVal.nVPos = nAtVertPosVal;
    1808             : 
    1809           0 :     aMgr.ValidateMetrics(aVal, mpToCharCntntPos, true);   // one time, to get reference values for percental values
    1810             : 
    1811             :     // set reference values for percental values (100%) ...
    1812           0 :     m_aWidthED.SetRefValue(aVal.aPercentSize.Width());
    1813           0 :     m_aHeightED.SetRefValue(aVal.aPercentSize.Height());
    1814             : 
    1815             :     // ... and correctly convert width and height with it
    1816           0 :     SwTwips nWidth  = static_cast< SwTwips >(m_aWidthED. DenormalizePercent(m_aWidthED.GetValue(FUNIT_TWIP)));
    1817           0 :     SwTwips nHeight = static_cast< SwTwips >(m_aHeightED.DenormalizePercent(m_aHeightED.GetValue(FUNIT_TWIP)));
    1818           0 :     aVal.nWidth  = nWidth;
    1819           0 :     aVal.nHeight = nHeight;
    1820             : 
    1821           0 :     aMgr.ValidateMetrics(aVal, mpToCharCntntPos);    // one more time, to determine all remaining values with correct width and height.
    1822             : 
    1823             :     // all columns have to be correct
    1824           0 :     if(GetTabDialog()->GetExampleSet() &&
    1825           0 :             SfxItemState::DEFAULT <= GetTabDialog()->GetExampleSet()->GetItemState(RES_COL))
    1826             :     {
    1827           0 :         const SwFmtCol& rCol = (const SwFmtCol&)GetTabDialog()->GetExampleSet()->Get(RES_COL);
    1828           0 :         if ( rCol.GetColumns().size() > 1 )
    1829             :         {
    1830           0 :             for ( size_t i = 0; i < rCol.GetColumns().size(); ++i )
    1831             :             {
    1832           0 :                 aVal.nMinWidth += rCol.GetColumns()[i].GetLeft() +
    1833           0 :                                   rCol.GetColumns()[i].GetRight() +
    1834           0 :                                   MINFLY;
    1835             :             }
    1836           0 :             aVal.nMinWidth -= MINFLY;//one was already in there!
    1837             :         }
    1838             :     }
    1839             : 
    1840           0 :     nWidth = aVal.nWidth;
    1841           0 :     nHeight = aVal.nHeight;
    1842             : 
    1843             :     // minimum range also for template
    1844           0 :     m_aHeightED.SetMin(m_aHeightED.NormalizePercent(aVal.nMinHeight), FUNIT_TWIP);
    1845           0 :     m_aWidthED. SetMin(m_aWidthED.NormalizePercent(aVal.nMinWidth), FUNIT_TWIP);
    1846             : 
    1847           0 :     SwTwips nMaxWidth(aVal.nMaxWidth);
    1848           0 :     SwTwips nMaxHeight(aVal.nMaxHeight);
    1849             : 
    1850           0 :     if (aVal.bAutoHeight && (sDlgType == "PictureDialog" || sDlgType == "ObjectDialog"))
    1851             :     {
    1852           0 :         SwTwips nTmp = std::min(nWidth * nMaxHeight / std::max(nHeight, 1L), nMaxHeight);
    1853           0 :         m_aWidthED.SetMax(m_aWidthED.NormalizePercent(nTmp), FUNIT_TWIP);
    1854             : 
    1855           0 :         nTmp = std::min(nHeight * nMaxWidth / std::max(nWidth, 1L), nMaxWidth);
    1856           0 :         m_aHeightED.SetMax(m_aWidthED.NormalizePercent(nTmp), FUNIT_TWIP);
    1857             :     }
    1858             :     else
    1859             :     {
    1860           0 :         SwTwips nTmp = static_cast< SwTwips >(m_aHeightED.NormalizePercent(nMaxHeight));
    1861           0 :         m_aHeightED.SetMax(nTmp, FUNIT_TWIP);
    1862             : 
    1863           0 :         nTmp = static_cast< SwTwips >(m_aWidthED.NormalizePercent(nMaxWidth));
    1864           0 :         m_aWidthED.SetMax(nTmp, FUNIT_TWIP);
    1865             :     }
    1866             : 
    1867           0 :     m_pAtHorzPosED->SetMin(m_pAtHorzPosED->Normalize(aVal.nMinHPos), FUNIT_TWIP);
    1868           0 :     m_pAtHorzPosED->SetMax(m_pAtHorzPosED->Normalize(aVal.nMaxHPos), FUNIT_TWIP);
    1869           0 :     if ( aVal.nHPos != nAtHorzPosVal )
    1870           0 :         m_pAtHorzPosED->SetValue(m_pAtHorzPosED->Normalize(aVal.nHPos), FUNIT_TWIP);
    1871             : 
    1872           0 :     const SwTwips nUpperOffset = (aVal.nAnchorType == FLY_AS_CHAR)
    1873           0 :         ? nUpperBorder : 0;
    1874           0 :     const SwTwips nLowerOffset = (aVal.nAnchorType == FLY_AS_CHAR)
    1875           0 :         ? nLowerBorder : 0;
    1876             : 
    1877           0 :     m_pAtVertPosED->SetMin(m_pAtVertPosED->Normalize(aVal.nMinVPos + nLowerOffset + nUpperOffset), FUNIT_TWIP);
    1878           0 :     m_pAtVertPosED->SetMax(m_pAtVertPosED->Normalize(aVal.nMaxVPos), FUNIT_TWIP);
    1879           0 :     if ( aVal.nVPos != nAtVertPosVal )
    1880           0 :         m_pAtVertPosED->SetValue(m_pAtVertPosED->Normalize(aVal.nVPos), FUNIT_TWIP);
    1881             : 
    1882           0 :     return 0;
    1883             : }
    1884             : 
    1885           0 : IMPL_LINK_NOARG(SwFrmPage, AnchorTypeHdl)
    1886             : {
    1887           0 :     m_pMirrorPagesCB->Enable(!m_pAnchorAsCharRB->IsChecked());
    1888             : 
    1889             :     // i#18732 - enable check box 'Follow text flow' for anchor
    1890             :     // type to-paragraph' and to-character
    1891             :     // i#22305 - enable check box 'Follow text
    1892             :     // flow' also for anchor type to-frame.
    1893           0 :     m_pFollowTextFlowCB->Enable( m_pAnchorAtParaRB->IsChecked() ||
    1894           0 :                               m_pAnchorAtCharRB->IsChecked() ||
    1895           0 :                               m_pAnchorAtFrameRB->IsChecked() );
    1896             : 
    1897           0 :     RndStdIds eId = GetAnchor();
    1898             : 
    1899           0 :     InitPos( eId, -1, 0, -1, 0, LONG_MAX, LONG_MAX);
    1900           0 :     RangeModifyHdl(0);
    1901             : 
    1902           0 :     if(bHtmlMode)
    1903             :     {
    1904           0 :         PosHdl(m_pHorizontalDLB);
    1905           0 :         PosHdl(m_pVerticalDLB);
    1906             :     }
    1907             : 
    1908           0 :     EnableVerticalPositioning( !(m_bIsMathOLE && m_bIsMathBaselineAlignment
    1909           0 :             && FLY_AS_CHAR == eId) );
    1910             : 
    1911           0 :     return 0;
    1912             : }
    1913             : 
    1914           0 : IMPL_LINK( SwFrmPage, PosHdl, ListBox *, pLB )
    1915             : {
    1916           0 :     bool bHori = pLB == m_pHorizontalDLB;
    1917           0 :     ListBox *pRelLB = bHori ? m_pHoriRelationLB : m_pVertRelationLB;
    1918           0 :     FixedText *pRelFT = bHori ? m_pHoriRelationFT : m_pVertRelationFT;
    1919           0 :     FrmMap *pMap = bHori ? pHMap : pVMap;
    1920             : 
    1921           0 :     const sal_Int32 nMapPos = GetMapPos(pMap, *pLB);
    1922           0 :     const sal_Int16 nAlign = GetAlignment(pMap, nMapPos, *pLB, *pRelLB);
    1923             : 
    1924           0 :     if (bHori)
    1925             :     {
    1926           0 :         bool bEnable = text::HoriOrientation::NONE == nAlign;
    1927           0 :         m_pAtHorzPosED->Enable( bEnable );
    1928           0 :         m_pAtHorzPosFT->Enable( bEnable );
    1929             :     }
    1930             :     else
    1931             :     {
    1932           0 :         bool bEnable = text::VertOrientation::NONE == nAlign && m_bAllowVertPositioning;
    1933           0 :         m_pAtVertPosED->Enable( bEnable );
    1934           0 :         m_pAtVertPosFT->Enable( bEnable );
    1935             :     }
    1936             : 
    1937           0 :     RangeModifyHdl( 0 );
    1938             : 
    1939           0 :     sal_Int16 nRel = 0;
    1940           0 :     if (pLB->GetSelectEntryCount())
    1941             :     {
    1942             : 
    1943           0 :         if (pRelLB->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND)
    1944           0 :             nRel = ((RelationMap *)pRelLB->GetEntryData(pRelLB->GetSelectEntryPos()))->nRelation;
    1945             : 
    1946           0 :         FillRelLB(pMap, nMapPos, nAlign, nRel, *pRelLB, *pRelFT);
    1947             :     }
    1948             :     else
    1949           0 :         pRelLB->Clear();
    1950             : 
    1951           0 :     UpdateExample();
    1952             : 
    1953           0 :     if (bHori)
    1954           0 :         bAtHorzPosModified = true;
    1955             :     else
    1956           0 :         bAtVertPosModified = true;
    1957             : 
    1958             :     // special treatment for HTML-Mode with horizonal-vertical-dependencies
    1959           0 :     if(bHtmlMode && (FLY_AT_CHAR == GetAnchor()))
    1960             :     {
    1961           0 :         bool bSet = false;
    1962           0 :         if(bHori)
    1963             :         {
    1964             :             // right is allowed only above - from the left only above
    1965             :             // from the left at character -> below
    1966           0 :             if((text::HoriOrientation::LEFT == nAlign || text::HoriOrientation::RIGHT == nAlign) &&
    1967           0 :                     0 == m_pVerticalDLB->GetSelectEntryPos())
    1968             :             {
    1969           0 :                 if(text::RelOrientation::FRAME == nRel)
    1970           0 :                     m_pVerticalDLB->SelectEntryPos(1);
    1971             :                 else
    1972           0 :                     m_pVerticalDLB->SelectEntryPos(0);
    1973           0 :                 bSet = true;
    1974             :             }
    1975           0 :             else if(text::HoriOrientation::LEFT == nAlign && 1 == m_pVerticalDLB->GetSelectEntryPos())
    1976             :             {
    1977           0 :                 m_pVerticalDLB->SelectEntryPos(0);
    1978           0 :                 bSet = true;
    1979             :             }
    1980           0 :             else if(text::HoriOrientation::NONE == nAlign && 1 == m_pVerticalDLB->GetSelectEntryPos())
    1981             :             {
    1982           0 :                 m_pVerticalDLB->SelectEntryPos(0);
    1983           0 :                 bSet = true;
    1984             :             }
    1985           0 :             if(bSet)
    1986           0 :                 PosHdl(m_pVerticalDLB);
    1987             :         }
    1988             :         else
    1989             :         {
    1990           0 :             if(text::VertOrientation::TOP == nAlign)
    1991             :             {
    1992           0 :                 if(1 == m_pHorizontalDLB->GetSelectEntryPos())
    1993             :                 {
    1994           0 :                     m_pHorizontalDLB->SelectEntryPos(0);
    1995           0 :                     bSet = true;
    1996             :                 }
    1997           0 :                 m_pHoriRelationLB->SelectEntryPos(1);
    1998             :             }
    1999           0 :             else if(text::VertOrientation::CHAR_BOTTOM == nAlign)
    2000             :             {
    2001           0 :                 if(2 == m_pHorizontalDLB->GetSelectEntryPos())
    2002             :                 {
    2003           0 :                     m_pHorizontalDLB->SelectEntryPos(0);
    2004           0 :                     bSet = true;
    2005             :                 }
    2006           0 :                 m_pHoriRelationLB->SelectEntryPos(0) ;
    2007             :             }
    2008           0 :             if(bSet)
    2009           0 :                 PosHdl(m_pHorizontalDLB);
    2010             :         }
    2011             : 
    2012             :     }
    2013           0 :     return 0;
    2014             : }
    2015             : 
    2016             : //  horizontal Pos
    2017           0 : IMPL_LINK( SwFrmPage, RelHdl, ListBox *, pLB )
    2018             : {
    2019           0 :     bool bHori = pLB == m_pHoriRelationLB;
    2020             : 
    2021           0 :     UpdateExample();
    2022             : 
    2023           0 :     if (bHori)
    2024           0 :         bAtHorzPosModified = true;
    2025             :     else
    2026           0 :         bAtVertPosModified = true;
    2027             : 
    2028           0 :     if (bHtmlMode && (FLY_AT_CHAR == GetAnchor()))
    2029             :     {
    2030           0 :         if(bHori)
    2031             :         {
    2032           0 :             const sal_Int16 nRel = GetRelation(pHMap, *m_pHoriRelationLB);
    2033           0 :             if(text::RelOrientation::PRINT_AREA == nRel && 0 == m_pVerticalDLB->GetSelectEntryPos())
    2034             :             {
    2035           0 :                 m_pVerticalDLB->SelectEntryPos(1);
    2036             :             }
    2037           0 :             else if(text::RelOrientation::CHAR == nRel && 1 == m_pVerticalDLB->GetSelectEntryPos())
    2038             :             {
    2039           0 :                 m_pVerticalDLB->SelectEntryPos(0);
    2040             :             }
    2041             :         }
    2042             :     }
    2043           0 :     if (pLB)    // Only when Handler was called by changing of the controller
    2044           0 :         RangeModifyHdl(0);
    2045             : 
    2046           0 :     return 0;
    2047             : }
    2048             : 
    2049           0 : IMPL_LINK_NOARG_INLINE_START(SwFrmPage, RealSizeHdl)
    2050             : {
    2051           0 :     m_aWidthED.SetUserValue( m_aWidthED. NormalizePercent(aGrfSize.Width() ), FUNIT_TWIP);
    2052           0 :     m_aHeightED.SetUserValue(m_aHeightED.NormalizePercent(aGrfSize.Height()), FUNIT_TWIP);
    2053           0 :     fWidthHeightRatio = aGrfSize.Height() ? double(aGrfSize.Width()) / double(aGrfSize.Height()) : 1.0;
    2054           0 :     UpdateExample();
    2055           0 :     return 0;
    2056             : }
    2057           0 : IMPL_LINK_NOARG_INLINE_END(SwFrmPage, RealSizeHdl)
    2058             : 
    2059           0 : IMPL_LINK_NOARG(SwFrmPage, AutoWidthClickHdl)
    2060             : {
    2061           0 :     if( !IsInGraficMode() )
    2062           0 :         HandleAutoCB( m_pAutoWidthCB->IsChecked(), *m_pWidthFT, *m_pWidthAutoFT, *m_aWidthED.get() );
    2063           0 :     return 0;
    2064             : }
    2065             : 
    2066           0 : IMPL_LINK_NOARG(SwFrmPage, AutoHeightClickHdl)
    2067             : {
    2068           0 :     if( !IsInGraficMode() )
    2069           0 :         HandleAutoCB( m_pAutoHeightCB->IsChecked(), *m_pHeightFT, *m_pHeightAutoFT, *m_aWidthED.get() );
    2070           0 :     return 0;
    2071             : }
    2072             : 
    2073           0 : IMPL_LINK( SwFrmPage, ModifyHdl, Edit *, pEdit )
    2074             : {
    2075           0 :     SwTwips nWidth  = static_cast< SwTwips >(m_aWidthED.DenormalizePercent(m_aWidthED.GetValue(FUNIT_TWIP)));
    2076           0 :     SwTwips nHeight = static_cast< SwTwips >(m_aHeightED.DenormalizePercent(m_aHeightED.GetValue(FUNIT_TWIP)));
    2077           0 :     if ( m_pFixedRatioCB->IsChecked() )
    2078             :     {
    2079           0 :         if (pEdit == m_aWidthED.get())
    2080             :         {
    2081           0 :             nHeight = SwTwips((double)nWidth / fWidthHeightRatio);
    2082           0 :             m_aHeightED.SetPrcntValue(m_aHeightED.NormalizePercent(nHeight), FUNIT_TWIP);
    2083             :         }
    2084           0 :         else if (pEdit == m_aHeightED.get())
    2085             :         {
    2086           0 :             nWidth = SwTwips((double)nHeight * fWidthHeightRatio);
    2087           0 :             m_aWidthED.SetPrcntValue(m_aWidthED.NormalizePercent(nWidth), FUNIT_TWIP);
    2088             :         }
    2089             :     }
    2090           0 :     fWidthHeightRatio = nHeight ? double(nWidth) / double(nHeight) : 1.0;
    2091           0 :     UpdateExample();
    2092           0 :     return 0;
    2093             : }
    2094             : 
    2095           0 : void SwFrmPage::UpdateExample()
    2096             : {
    2097           0 :     sal_Int32 nPos = m_pHorizontalDLB->GetSelectEntryPos();
    2098           0 :     if ( pHMap && nPos != LISTBOX_ENTRY_NOTFOUND )
    2099             :     {
    2100           0 :         const sal_Int32 nMapPos = GetMapPos(pHMap, *m_pHorizontalDLB);
    2101           0 :         m_pExampleWN->SetHAlign(GetAlignment(pHMap, nMapPos, *m_pHorizontalDLB, *m_pHoriRelationLB));
    2102           0 :         m_pExampleWN->SetHoriRel(GetRelation(pHMap, *m_pHoriRelationLB));
    2103             :     }
    2104             : 
    2105           0 :     nPos = m_pVerticalDLB->GetSelectEntryPos();
    2106           0 :     if ( pVMap && nPos != LISTBOX_ENTRY_NOTFOUND )
    2107             :     {
    2108           0 :         const sal_Int32 nMapPos = GetMapPos(pVMap, *m_pVerticalDLB);
    2109           0 :         m_pExampleWN->SetVAlign(GetAlignment(pVMap, nMapPos, *m_pVerticalDLB, *m_pVertRelationLB));
    2110           0 :         m_pExampleWN->SetVertRel(GetRelation(pVMap, *m_pVertRelationLB));
    2111             :     }
    2112             : 
    2113             :     // size
    2114           0 :     long nXPos = static_cast< long >(m_pAtHorzPosED->Denormalize(m_pAtHorzPosED->GetValue(FUNIT_TWIP)));
    2115           0 :     long nYPos = static_cast< long >(m_pAtVertPosED->Denormalize(m_pAtVertPosED->GetValue(FUNIT_TWIP)));
    2116           0 :     m_pExampleWN->SetRelPos(Point(nXPos, nYPos));
    2117             : 
    2118           0 :     m_pExampleWN->SetAnchor( static_cast< sal_Int16 >(GetAnchor()) );
    2119           0 :     m_pExampleWN->Invalidate();
    2120           0 : }
    2121             : 
    2122           0 : void SwFrmPage::Init(const SfxItemSet& rSet, bool bReset)
    2123             : {
    2124           0 :     if(!bFormat)
    2125             :     {
    2126           0 :         SwWrtShell* pSh = getFrmDlgParentShell();
    2127             : 
    2128             :         // size
    2129           0 :         const bool bSizeFixed = pSh->IsSelObjProtected( FLYPROTECT_FIXED );
    2130             : 
    2131           0 :         m_aWidthED .Enable( !bSizeFixed );
    2132           0 :         m_aHeightED.Enable( !bSizeFixed );
    2133             : 
    2134             :         // size controls for math OLE objects
    2135           0 :         if ( sDlgType == "ObjectDialog" && ! bNew )
    2136             :         {
    2137             :             // disable width and height for math objects
    2138           0 :             const SvGlobalName& rFactNm( pSh->GetOLEObject()->getClassID() );
    2139             : 
    2140             :             struct _GlobalNameId {
    2141             :                 sal_uInt32 n1;
    2142             :                 sal_uInt16 n2, n3;
    2143             :                 sal_uInt8 b8, b9, b10, b11, b12, b13, b14, b15;
    2144             :             } aGlbNmIds[4] = { { SO3_SM_CLASSID_60 }, { SO3_SM_CLASSID_50 },
    2145           0 :                                { SO3_SM_CLASSID_40 }, { SO3_SM_CLASSID_30 } };
    2146             : 
    2147           0 :             for ( int i = 0; i < 4; ++i ) {
    2148           0 :                 const _GlobalNameId& rId = aGlbNmIds[ i ];
    2149             : 
    2150             :                 SvGlobalName aGlbNm( rId.n1, rId.n2, rId.n3,
    2151             :                                      rId.b8, rId.b9, rId.b10, rId.b11,
    2152           0 :                                      rId.b12, rId.b13, rId.b14, rId.b15 );
    2153             : 
    2154           0 :                 if( rFactNm == aGlbNm )
    2155             :                 {
    2156             :                     // disable size controls for math OLE objects
    2157           0 :                     m_pWidthFT->Disable();
    2158           0 :                     m_aWidthED.Disable();
    2159           0 :                     m_pRelWidthCB->Disable();
    2160           0 :                     m_pHeightFT->Disable();
    2161           0 :                     m_aHeightED.Disable();
    2162           0 :                     m_pRelHeightCB->Disable();
    2163           0 :                     m_pFixedRatioCB->Disable();
    2164           0 :                     m_pRealSizeBT->Disable();
    2165           0 :                     break;
    2166             :                 }
    2167           0 :             }
    2168             : 
    2169             :             // TODO/LATER: get correct aspect
    2170           0 :             if(0 != (pSh->GetOLEObject()->getStatus( embed::Aspects::MSOLE_CONTENT ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE ) )
    2171           0 :                 m_pRealSizeBT->Disable();
    2172             :         }
    2173             :     }
    2174             : 
    2175           0 :     const SwFmtFrmSize& rSize = (const SwFmtFrmSize&)rSet.Get(RES_FRM_SIZE);
    2176           0 :     sal_Int64 nWidth  = m_aWidthED.NormalizePercent(rSize.GetWidth());
    2177           0 :     sal_Int64 nHeight = m_aHeightED.NormalizePercent(rSize.GetHeight());
    2178             : 
    2179           0 :     if (nWidth != m_aWidthED.GetValue(FUNIT_TWIP))
    2180             :     {
    2181           0 :         if(!bReset)
    2182             :         {
    2183             :             // value was changed by circulation-Tabpage and
    2184             :             // has to be set with Modify-Flag
    2185           0 :             m_aWidthED.SetUserValue(nWidth, FUNIT_TWIP);
    2186             :         }
    2187             :         else
    2188           0 :             m_aWidthED.SetPrcntValue(nWidth, FUNIT_TWIP);
    2189             :     }
    2190             : 
    2191           0 :     if (nHeight != m_aHeightED.GetValue(FUNIT_TWIP))
    2192             :     {
    2193           0 :         if (!bReset)
    2194             :         {
    2195             :             // values was changed by circulation-Tabpage and
    2196             :             // has to be set with Modify-Flag
    2197           0 :             m_aHeightED.SetUserValue(nHeight, FUNIT_TWIP);
    2198             :         }
    2199             :         else
    2200           0 :             m_aHeightED.SetPrcntValue(nHeight, FUNIT_TWIP);
    2201             :     }
    2202             : 
    2203           0 :     if (!IsInGraficMode())
    2204             :     {
    2205           0 :         SwFrmSize eSize = rSize.GetHeightSizeType();
    2206           0 :         bool bCheck = eSize != ATT_FIX_SIZE;
    2207           0 :         m_pAutoHeightCB->Check( bCheck );
    2208           0 :         HandleAutoCB( bCheck, *m_pHeightFT, *m_pHeightAutoFT, *m_aWidthED.get() );
    2209           0 :         if( eSize == ATT_VAR_SIZE )
    2210           0 :             m_aHeightED.SetValue( m_aHeightED.GetMin(), FUNIT_NONE );
    2211             : 
    2212           0 :         eSize = rSize.GetWidthSizeType();
    2213           0 :         bCheck = eSize != ATT_FIX_SIZE;
    2214           0 :         m_pAutoWidthCB->Check( bCheck );
    2215           0 :         HandleAutoCB( bCheck, *m_pWidthFT, *m_pWidthAutoFT, *m_aWidthED.get() );
    2216           0 :         if( eSize == ATT_VAR_SIZE )
    2217           0 :             m_aWidthED.SetValue( m_aWidthED.GetMin(), FUNIT_NONE );
    2218             : 
    2219           0 :         if ( !bFormat )
    2220             :         {
    2221           0 :             SwWrtShell* pSh = getFrmDlgParentShell();
    2222           0 :             const SwFrmFmt* pFmt = pSh->GetFlyFrmFmt();
    2223           0 :             if( pFmt && pFmt->GetChain().GetNext() )
    2224           0 :                 m_pAutoHeightCB->Enable( false );
    2225             :         }
    2226             :     }
    2227             :     else
    2228           0 :         m_pAutoHeightCB->Hide();
    2229             : 
    2230             :     // organise circulation-gap for character bound frames
    2231           0 :     const SvxULSpaceItem &rUL = (const SvxULSpaceItem &)rSet.Get(RES_UL_SPACE);
    2232           0 :     nUpperBorder = rUL.GetUpper();
    2233           0 :     nLowerBorder = rUL.GetLower();
    2234             : 
    2235           0 :     if(SfxItemState::SET == rSet.GetItemState(FN_KEEP_ASPECT_RATIO))
    2236             :     {
    2237           0 :         m_pFixedRatioCB->Check(((const SfxBoolItem&)rSet.Get(FN_KEEP_ASPECT_RATIO)).GetValue());
    2238           0 :         m_pFixedRatioCB->SaveValue();
    2239             :     }
    2240             : 
    2241             :     // columns
    2242           0 :     SwFmtCol aCol( (const SwFmtCol&)rSet.Get(RES_COL) );
    2243           0 :     ::FitToActualSize( aCol, (sal_uInt16)rSize.GetWidth() );
    2244             : 
    2245           0 :     RndStdIds eAnchorId = (RndStdIds)GetAnchor();
    2246             : 
    2247           0 :     if ( bNew && !bFormat )
    2248           0 :         InitPos(eAnchorId, -1, 0, -1, 0, LONG_MAX, LONG_MAX);
    2249             :     else
    2250             :     {
    2251           0 :         const SwFmtHoriOrient& rHori = (const SwFmtHoriOrient&)rSet.Get(RES_HORI_ORIENT);
    2252           0 :         const SwFmtVertOrient& rVert = (const SwFmtVertOrient&)rSet.Get(RES_VERT_ORIENT);
    2253           0 :         nOldH    = rHori.GetHoriOrient();
    2254           0 :         nOldHRel = rHori.GetRelationOrient();
    2255           0 :         nOldV    = rVert.GetVertOrient(),
    2256           0 :         nOldVRel = rVert.GetRelationOrient();
    2257             : 
    2258           0 :         if (eAnchorId == FLY_AT_PAGE)
    2259             :         {
    2260           0 :             if (nOldHRel == text::RelOrientation::FRAME)
    2261           0 :                 nOldHRel = text::RelOrientation::PAGE_FRAME;
    2262           0 :             else if (nOldHRel == text::RelOrientation::PRINT_AREA)
    2263           0 :                 nOldHRel = text::RelOrientation::PAGE_PRINT_AREA;
    2264           0 :             if (nOldVRel == text::RelOrientation::FRAME)
    2265           0 :                 nOldVRel = text::RelOrientation::PAGE_FRAME;
    2266           0 :             else if (nOldVRel == text::RelOrientation::PRINT_AREA)
    2267           0 :                 nOldVRel = text::RelOrientation::PAGE_PRINT_AREA;
    2268             :         }
    2269             : 
    2270           0 :         m_pMirrorPagesCB->Check(rHori.IsPosToggle());
    2271           0 :         m_pMirrorPagesCB->SaveValue();
    2272             : 
    2273             :         InitPos(eAnchorId,
    2274             :                 nOldH,
    2275             :                 nOldHRel,
    2276             :                 nOldV,
    2277             :                 nOldVRel,
    2278             :                 rHori.GetPos(),
    2279           0 :                 rVert.GetPos());
    2280             :     }
    2281             : 
    2282             :     // transparent for example
    2283             :     // circulation for example
    2284           0 :     const SwFmtSurround& rSurround = (const SwFmtSurround&)rSet.Get(RES_SURROUND);
    2285           0 :     m_pExampleWN->SetWrap ( static_cast< sal_uInt16 >(rSurround.GetSurround()) );
    2286             : 
    2287           0 :     if ( rSurround.GetSurround() == SURROUND_THROUGHT )
    2288             :     {
    2289           0 :         const SvxOpaqueItem& rOpaque = (const SvxOpaqueItem&)rSet.Get(RES_OPAQUE);
    2290           0 :         m_pExampleWN->SetTransparent(!rOpaque.GetValue());
    2291             :     }
    2292             : 
    2293             :     // switch to percent if applicable
    2294           0 :     RangeModifyHdl(&m_aWidthED);  // set reference values (for 100%)
    2295             : 
    2296           0 :     if (rSize.GetWidthPercent() == 0xff || rSize.GetHeightPercent() == 0xff)
    2297           0 :         m_pFixedRatioCB->Check(true);
    2298           0 :     if (rSize.GetWidthPercent() && rSize.GetWidthPercent() != 0xff &&
    2299           0 :         !m_pRelWidthCB->IsChecked())
    2300             :     {
    2301           0 :         m_pRelWidthCB->Check(true);
    2302           0 :         RelSizeClickHdl(m_pRelWidthCB);
    2303           0 :         m_aWidthED.SetPrcntValue(rSize.GetWidthPercent(), FUNIT_CUSTOM);
    2304             :     }
    2305           0 :     if (rSize.GetHeightPercent() && rSize.GetHeightPercent() != 0xff &&
    2306           0 :         !m_pRelHeightCB->IsChecked())
    2307             :     {
    2308           0 :         m_pRelHeightCB->Check(true);
    2309           0 :         RelSizeClickHdl(m_pRelHeightCB);
    2310           0 :         m_aHeightED.SetPrcntValue(rSize.GetHeightPercent(), FUNIT_CUSTOM);
    2311             :     }
    2312           0 :     m_pRelWidthCB->SaveValue();
    2313           0 :     m_pRelHeightCB->SaveValue();
    2314             : 
    2315           0 :     if (rSize.GetWidthPercentRelation() == text::RelOrientation::PAGE_FRAME)
    2316           0 :         m_pRelWidthRelationLB->SelectEntryPos(1);
    2317             :     else
    2318           0 :         m_pRelWidthRelationLB->SelectEntryPos(0);
    2319             : 
    2320           0 :     if (rSize.GetHeightPercentRelation() == text::RelOrientation::PAGE_FRAME)
    2321           0 :         m_pRelHeightRelationLB->SelectEntryPos(1);
    2322             :     else
    2323           0 :         m_pRelHeightRelationLB->SelectEntryPos(0);
    2324           0 : }
    2325             : 
    2326           0 : const sal_uInt16* SwFrmPage::GetRanges()
    2327             : {
    2328           0 :     return aPageRg;
    2329             : }
    2330             : 
    2331           0 : void SwFrmPage::SetFormatUsed(bool bFmt)
    2332             : {
    2333           0 :     bFormat = bFmt;
    2334           0 :     if(bFormat)
    2335             :     {
    2336           0 :         m_pAnchorFrame->Hide();
    2337             :     }
    2338           0 : }
    2339             : 
    2340           0 : void SwFrmPage::EnableVerticalPositioning( bool bEnable )
    2341             : {
    2342           0 :     m_bAllowVertPositioning = bEnable;
    2343           0 :     m_pVerticalFT->Enable( bEnable );
    2344           0 :     m_pVerticalDLB->Enable( bEnable );
    2345           0 :     m_pAtVertPosFT->Enable( bEnable );
    2346           0 :     m_pAtVertPosED->Enable( bEnable );
    2347           0 :     m_pVertRelationFT->Enable( bEnable );
    2348           0 :     m_pVertRelationLB->Enable( bEnable );
    2349           0 : }
    2350             : 
    2351           0 : SwGrfExtPage::SwGrfExtPage(vcl::Window *pParent, const SfxItemSet &rSet)
    2352             :     : SfxTabPage(pParent, "PicturePage",
    2353             :         "modules/swriter/ui/picturepage.ui", &rSet)
    2354             :     , pGrfDlg(0)
    2355           0 :     , bHtmlMode(false)
    2356             : {
    2357           0 :     get(m_pMirror, "flipframe");
    2358           0 :     get(m_pMirrorVertBox, "vert");
    2359           0 :     get(m_pMirrorHorzBox, "hori");
    2360           0 :     get(m_pAllPagesRB, "allpages");
    2361           0 :     get(m_pLeftPagesRB, "leftpages");
    2362           0 :     get(m_pRightPagesRB, "rightpages");
    2363           0 :     get(m_pConnectED, "entry");
    2364           0 :     get(m_pBrowseBT, "browse");
    2365           0 :     get(m_pBmpWin, "preview");
    2366           0 :     m_pBmpWin->SetBitmapEx(get<FixedImage>("fallback")->GetImage().GetBitmapEx());
    2367             : 
    2368           0 :     SetExchangeSupport();
    2369           0 :     m_pMirrorHorzBox->SetClickHdl( LINK(this, SwGrfExtPage, MirrorHdl));
    2370           0 :     m_pMirrorVertBox->SetClickHdl( LINK(this, SwGrfExtPage, MirrorHdl));
    2371           0 :     m_pBrowseBT->SetClickHdl    ( LINK(this, SwGrfExtPage, BrowseHdl));
    2372           0 : }
    2373             : 
    2374           0 : SwGrfExtPage::~SwGrfExtPage()
    2375             : {
    2376           0 :     delete pGrfDlg;
    2377           0 : }
    2378             : 
    2379           0 : SfxTabPage* SwGrfExtPage::Create( vcl::Window *pParent, const SfxItemSet *rSet )
    2380             : {
    2381           0 :     return new SwGrfExtPage( pParent, *rSet );
    2382             : }
    2383             : 
    2384           0 : void SwGrfExtPage::Reset(const SfxItemSet *rSet)
    2385             : {
    2386             :     const SfxPoolItem* pItem;
    2387           0 :     const sal_uInt16 nHtmlMode = ::GetHtmlMode((const SwDocShell*)SfxObjectShell::Current());
    2388           0 :     bHtmlMode = nHtmlMode & HTMLMODE_ON ? sal_True : sal_False;
    2389             : 
    2390           0 :     if( SfxItemState::SET == rSet->GetItemState( FN_PARAM_GRF_CONNECT, true, &pItem)
    2391           0 :         && ((const SfxBoolItem *)pItem)->GetValue() )
    2392             :     {
    2393           0 :         m_pBrowseBT->Enable();
    2394           0 :         m_pConnectED->SetReadOnly(false);
    2395             :     }
    2396             : 
    2397           0 :     ActivatePage(*rSet);
    2398           0 : }
    2399             : 
    2400           0 : void SwGrfExtPage::ActivatePage(const SfxItemSet& rSet)
    2401             : {
    2402           0 :     const SvxProtectItem& rProt = (const SvxProtectItem& )rSet.Get(RES_PROTECT);
    2403           0 :     bool bProtCntnt = rProt.IsCntntProtected();
    2404             : 
    2405           0 :     const SfxPoolItem* pItem = 0;
    2406           0 :     bool bEnable = false;
    2407           0 :     bool bEnableMirrorRB = false;
    2408             : 
    2409           0 :     SfxItemState eState = rSet.GetItemState(RES_GRFATR_MIRRORGRF, true, &pItem);
    2410           0 :     if( SfxItemState::UNKNOWN != eState && !bProtCntnt && !bHtmlMode )
    2411             :     {
    2412           0 :         if( SfxItemState::SET != eState )
    2413           0 :             pItem = &rSet.Get( RES_GRFATR_MIRRORGRF );
    2414             : 
    2415           0 :         bEnable = true;
    2416             : 
    2417           0 :         MirrorGraph eMirror = static_cast< MirrorGraph >(((const SwMirrorGrf* )pItem)->GetValue());
    2418           0 :         switch( eMirror )
    2419             :         {
    2420           0 :         case RES_MIRROR_GRAPH_DONT: break;
    2421           0 :         case RES_MIRROR_GRAPH_VERT: m_pMirrorHorzBox->Check(true); break;
    2422           0 :         case RES_MIRROR_GRAPH_HOR:  m_pMirrorVertBox->Check(true); break;
    2423           0 :         case RES_MIRROR_GRAPH_BOTH: m_pMirrorHorzBox->Check(true);
    2424           0 :                                     m_pMirrorVertBox->Check(true);
    2425           0 :                                     break;
    2426             :         default:
    2427             :             ;
    2428             :         }
    2429             : 
    2430           0 :         const int nPos = (((const SwMirrorGrf* )pItem)->IsGrfToggle() ? 1 : 0)
    2431           0 :             + ((eMirror == RES_MIRROR_GRAPH_VERT || eMirror == RES_MIRROR_GRAPH_BOTH) ? 2 : 0);
    2432             : 
    2433           0 :         bEnableMirrorRB = nPos != 0;
    2434             : 
    2435           0 :         switch (nPos)
    2436             :         {
    2437             :             case 1: // mirror at left / even pages
    2438           0 :                 m_pLeftPagesRB->Check();
    2439           0 :                 m_pMirrorHorzBox->Check(true);
    2440           0 :                 break;
    2441             :             case 2: // mirror on all pages
    2442           0 :                 m_pAllPagesRB->Check();
    2443           0 :                 break;
    2444             :             case 3: // mirror on right / odd pages
    2445           0 :                 m_pRightPagesRB->Check();
    2446           0 :                 break;
    2447             :             default:
    2448           0 :                 m_pAllPagesRB->Check();
    2449           0 :                 break;
    2450             :         }
    2451             :     }
    2452             : 
    2453           0 :     if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_GRAF_GRAPHIC, false, &pItem ) )
    2454             :     {
    2455           0 :         const SvxBrushItem& rBrush = *(SvxBrushItem*)pItem;
    2456           0 :         if( !rBrush.GetGraphicLink().isEmpty() )
    2457             :         {
    2458           0 :             aGrfName = aNewGrfName = rBrush.GetGraphicLink();
    2459           0 :             m_pConnectED->SetText( aNewGrfName );
    2460             :         }
    2461           0 :         OUString referer;
    2462             :         SfxStringItem const * it = static_cast<SfxStringItem const *>(
    2463           0 :             rSet.GetItem(SID_REFERER));
    2464           0 :         if (it != 0) {
    2465           0 :             referer = it->GetValue();
    2466             :         }
    2467           0 :         const Graphic* pGrf = rBrush.GetGraphic(referer);
    2468           0 :         if( pGrf )
    2469           0 :             m_pBmpWin->SetGraphic( *pGrf );
    2470             :     }
    2471             : 
    2472           0 :     m_pAllPagesRB->Enable(bEnableMirrorRB);
    2473           0 :     m_pLeftPagesRB->Enable(bEnableMirrorRB);
    2474           0 :     m_pRightPagesRB->Enable(bEnableMirrorRB);
    2475           0 :     m_pMirror->Enable(bEnable);
    2476             : 
    2477           0 :     m_pAllPagesRB->SaveValue();
    2478           0 :     m_pLeftPagesRB->SaveValue();
    2479           0 :     m_pRightPagesRB->SaveValue();
    2480           0 :     m_pMirrorHorzBox->SaveValue();
    2481           0 :     m_pMirrorVertBox->SaveValue();
    2482             : 
    2483           0 :     m_pBmpWin->MirrorHorz( m_pMirrorVertBox->IsChecked() );
    2484           0 :     m_pBmpWin->MirrorVert( m_pMirrorHorzBox->IsChecked() );
    2485           0 :     m_pBmpWin->Invalidate();
    2486           0 : }
    2487             : 
    2488           0 : bool SwGrfExtPage::FillItemSet( SfxItemSet *rSet )
    2489             : {
    2490           0 :     bool bModified = false;
    2491           0 :     if ( m_pMirrorHorzBox->IsValueChangedFromSaved() ||
    2492           0 :          m_pMirrorVertBox->IsValueChangedFromSaved() ||
    2493           0 :          m_pAllPagesRB->IsValueChangedFromSaved() ||
    2494           0 :          m_pLeftPagesRB->IsValueChangedFromSaved() ||
    2495           0 :          m_pRightPagesRB->IsValueChangedFromSaved() )
    2496             :     {
    2497           0 :         bModified = true;
    2498             : 
    2499           0 :         bool bHori = false;
    2500             : 
    2501           0 :         if (m_pMirrorHorzBox->IsChecked() &&
    2502           0 :                 !m_pLeftPagesRB->IsChecked())
    2503           0 :             bHori = true;
    2504             : 
    2505             :         MirrorGraph eMirror;
    2506           0 :         eMirror = m_pMirrorVertBox->IsChecked() && bHori ?
    2507             :                     RES_MIRROR_GRAPH_BOTH : bHori ?
    2508           0 :                     RES_MIRROR_GRAPH_VERT : m_pMirrorVertBox->IsChecked() ?
    2509           0 :                     RES_MIRROR_GRAPH_HOR  : RES_MIRROR_GRAPH_DONT;
    2510             : 
    2511           0 :         bool bMirror = !m_pAllPagesRB->IsChecked();
    2512           0 :         SwMirrorGrf aMirror( eMirror );
    2513           0 :         aMirror.SetGrfToggle(bMirror );
    2514           0 :         rSet->Put( aMirror );
    2515             :     }
    2516             : 
    2517           0 :     if( aGrfName != aNewGrfName || m_pConnectED->IsModified() )
    2518             :     {
    2519           0 :         bModified = true;
    2520           0 :         aGrfName = m_pConnectED->GetText();
    2521             :         rSet->Put( SvxBrushItem( aGrfName, aFilterName, GPOS_LT,
    2522           0 :                                 SID_ATTR_GRAF_GRAPHIC ));
    2523             :     }
    2524           0 :     return bModified;
    2525             : }
    2526             : 
    2527           0 : int SwGrfExtPage::DeactivatePage(SfxItemSet *_pSet)
    2528             : {
    2529           0 :     if( _pSet )
    2530           0 :         FillItemSet( _pSet );
    2531           0 :     return sal_True;
    2532             : }
    2533             : 
    2534           0 : IMPL_LINK_NOARG(SwGrfExtPage, BrowseHdl)
    2535             : {
    2536           0 :     if(!pGrfDlg)
    2537             :     {
    2538             :         pGrfDlg = new FileDialogHelper(
    2539             :                 ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW,
    2540           0 :                 SFXWB_GRAPHIC );
    2541           0 :         pGrfDlg->SetTitle(get<VclFrame>("linkframe")->get_label());
    2542             :     }
    2543           0 :     pGrfDlg->SetDisplayDirectory( m_pConnectED->GetText() );
    2544           0 :     uno::Reference < ui::dialogs::XFilePicker > xFP = pGrfDlg->GetFilePicker();
    2545           0 :     uno::Reference < ui::dialogs::XFilePickerControlAccess > xCtrlAcc(xFP, uno::UNO_QUERY);
    2546           0 :     sal_Bool bTrue = sal_True;
    2547           0 :     uno::Any aVal(&bTrue, ::getBooleanCppuType());
    2548           0 :     xCtrlAcc->setValue( ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, aVal);
    2549             : 
    2550           0 :     if ( pGrfDlg->Execute() == ERRCODE_NONE )
    2551             :     {   // remember selected filter
    2552           0 :         aFilterName = pGrfDlg->GetCurrentFilter();
    2553           0 :         aNewGrfName = INetURLObject::decode( pGrfDlg->GetPath(),
    2554             :                                         '%',
    2555             :                                            INetURLObject::DECODE_UNAMBIGUOUS,
    2556           0 :                                         RTL_TEXTENCODING_UTF8 );
    2557           0 :         m_pConnectED->SetModifyFlag();
    2558           0 :         m_pConnectED->SetText( aNewGrfName );
    2559             :         //reset mirrors because maybe a Bitmap was swapped with
    2560             :         //another type of graphic that cannot be mirrored.
    2561           0 :         m_pMirrorVertBox->Check(false);
    2562           0 :         m_pMirrorHorzBox->Check(false);
    2563           0 :         m_pAllPagesRB->Enable(false);
    2564           0 :         m_pLeftPagesRB->Enable(false);
    2565           0 :         m_pRightPagesRB->Enable(false);
    2566           0 :         m_pBmpWin->MirrorHorz(false);
    2567           0 :         m_pBmpWin->MirrorVert(false);
    2568             : 
    2569           0 :         Graphic aGraphic;
    2570           0 :         (void)GraphicFilter::LoadGraphic(pGrfDlg->GetPath(), OUString(), aGraphic);
    2571           0 :         m_pBmpWin->SetGraphic(aGraphic);
    2572             : 
    2573           0 :         bool bEnable = GRAPHIC_BITMAP      == aGraphic.GetType() ||
    2574           0 :                             GRAPHIC_GDIMETAFILE == aGraphic.GetType();
    2575           0 :         m_pMirrorVertBox->Enable(bEnable);
    2576           0 :         m_pMirrorHorzBox->Enable(bEnable);
    2577           0 :         m_pAllPagesRB->Enable(bEnable);
    2578           0 :         m_pLeftPagesRB->Enable(bEnable);
    2579           0 :         m_pRightPagesRB->Enable(bEnable);
    2580             :     }
    2581           0 :     return 0;
    2582             : }
    2583             : 
    2584           0 : IMPL_LINK_NOARG(SwGrfExtPage, MirrorHdl)
    2585             : {
    2586           0 :     bool bEnable = m_pMirrorHorzBox->IsChecked();
    2587             : 
    2588           0 :     m_pBmpWin->MirrorHorz( m_pMirrorVertBox->IsChecked() );
    2589           0 :     m_pBmpWin->MirrorVert( bEnable );
    2590             : 
    2591           0 :     m_pAllPagesRB->Enable(bEnable);
    2592           0 :     m_pLeftPagesRB->Enable(bEnable);
    2593           0 :     m_pRightPagesRB->Enable(bEnable);
    2594             : 
    2595           0 :     if (!m_pAllPagesRB->IsChecked() && !m_pLeftPagesRB->IsChecked() && !m_pRightPagesRB->IsChecked())
    2596           0 :         m_pAllPagesRB->Check();
    2597             : 
    2598           0 :     return 0;
    2599             : }
    2600             : 
    2601             : // example window
    2602           0 : BmpWindow::BmpWindow(vcl::Window* pPar, WinBits nStyle)
    2603             :     : Window(pPar, nStyle)
    2604             :     , bHorz(false)
    2605             :     , bVert(false)
    2606             :     , bGraphic(false)
    2607           0 :     , bLeftAlign(false)
    2608             : {
    2609           0 :     SetBackground();
    2610           0 :     SetPaintTransparent(true);
    2611             :     // #i119307# the graphic might have transparency, set up white as the color
    2612             :     // to use when drawing a rectangle under the image
    2613           0 :     SetLineColor(COL_WHITE);
    2614           0 :     SetFillColor(COL_WHITE);
    2615           0 : }
    2616             : 
    2617           0 : Size BmpWindow::GetOptimalSize() const
    2618             : {
    2619           0 :     return LogicToPixel(Size(127 , 66), MapMode(MAP_APPFONT));
    2620             : }
    2621             : 
    2622           0 : extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeBmpWindow(vcl::Window *pParent, VclBuilder::stringmap &)
    2623             : {
    2624           0 :     return new BmpWindow(pParent, 0);
    2625             : }
    2626             : 
    2627           0 : void BmpWindow::Paint( const Rectangle& )
    2628             : {
    2629           0 :     Point aPntPos;
    2630           0 :     Size  aPntSz( GetSizePixel() );
    2631           0 :     Size  aGrfSize;
    2632           0 :     if(bGraphic)
    2633           0 :         aGrfSize = ::GetGraphicSizeTwip(aGraphic, this);
    2634             :     //it should show the default bitmap also if no graphic can be found
    2635           0 :     if(!aGrfSize.Width() && !aGrfSize.Height())
    2636           0 :         aGrfSize = PixelToLogic(aBmp.GetSizePixel());
    2637             : 
    2638           0 :     long nRelGrf = aGrfSize.Width() * 100L / aGrfSize.Height();
    2639           0 :     long nRelWin = aPntSz.Width() * 100L / aPntSz.Height();
    2640           0 :     if(nRelGrf < nRelWin)
    2641             :     {
    2642           0 :         const long nWidth = aPntSz.Width();
    2643             :         // if we use a replacement preview, try to draw at original size
    2644           0 :         if ( !bGraphic && ( aGrfSize.Width() <= aPntSz.Width() ) && ( aGrfSize.Height() <= aPntSz.Height() ) )
    2645             :         {
    2646           0 :             const long nHeight = aPntSz.Height();
    2647           0 :             aPntSz.Width() = aGrfSize.Width();
    2648           0 :             aPntSz.Height() = aGrfSize.Height();
    2649           0 :             aPntPos.Y() += (nHeight - aPntSz.Height()) / 2;
    2650             :         }
    2651             :         else
    2652           0 :             aPntSz.Width() = aPntSz.Height() * nRelGrf /100;
    2653             : 
    2654           0 :         if(!bLeftAlign)
    2655           0 :             aPntPos.X() += nWidth - aPntSz.Width() ;
    2656             :     }
    2657             : 
    2658           0 :     if ( bHorz )
    2659             :     {
    2660           0 :         aPntPos.Y()     += aPntSz.Height();
    2661           0 :         aPntPos.Y() --;
    2662           0 :         aPntSz.Height() *= -1;
    2663             :     }
    2664           0 :     if ( bVert )
    2665             :     {
    2666           0 :         aPntPos.X()     += aPntSz.Width();
    2667           0 :         aPntPos.X()--;
    2668           0 :         aPntSz.Width()  *= -1;
    2669             :     }
    2670             : 
    2671             :     // #i119307# clear window background, the graphic might have transparency
    2672           0 :     DrawRect(Rectangle(aPntPos, aPntSz));
    2673             : 
    2674           0 :     if ( bGraphic )
    2675           0 :         aGraphic.Draw( this, aPntPos, aPntSz );
    2676             :     else
    2677             :     {
    2678           0 :         DrawBitmapEx( aPntPos, aPntSz, aBmp );
    2679             :     }
    2680           0 : }
    2681             : 
    2682           0 : BmpWindow::~BmpWindow()
    2683             : {
    2684           0 : }
    2685             : 
    2686           0 : void BmpWindow::SetGraphic(const Graphic& rGrf)
    2687             : {
    2688           0 :     aGraphic = rGrf;
    2689           0 :     Size aGrfSize = ::GetGraphicSizeTwip(aGraphic, this);
    2690           0 :     bGraphic = aGrfSize.Width() && aGrfSize.Height();
    2691           0 :     Invalidate();
    2692           0 : }
    2693             : 
    2694           0 : void BmpWindow::SetBitmapEx(const BitmapEx& rBmp)
    2695             : {
    2696           0 :     aBmp = rBmp;
    2697           0 :     Invalidate();
    2698           0 : }
    2699             : 
    2700             : // set URL and ImageMap at frames
    2701           0 : SwFrmURLPage::SwFrmURLPage( vcl::Window *pParent, const SfxItemSet &rSet ) :
    2702           0 :     SfxTabPage(pParent, "FrmURLPage" , "modules/swriter/ui/frmurlpage.ui", &rSet)
    2703             : {
    2704           0 :     get(pURLED,"url");
    2705           0 :     get(pSearchPB,"search");
    2706           0 :     get(pNameED,"name");
    2707           0 :     get(pFrameCB,"frame");
    2708             : 
    2709           0 :     get(pServerCB,"server");
    2710           0 :     get(pClientCB,"client");
    2711             : 
    2712           0 :     pSearchPB->SetClickHdl(LINK(this, SwFrmURLPage, InsertFileHdl));
    2713           0 : }
    2714             : 
    2715           0 : SwFrmURLPage::~SwFrmURLPage()
    2716             : {
    2717           0 : }
    2718             : 
    2719           0 : void SwFrmURLPage::Reset( const SfxItemSet *rSet )
    2720             : {
    2721             :     const SfxPoolItem* pItem;
    2722           0 :     if ( SfxItemState::SET == rSet->GetItemState( SID_DOCFRAME, true, &pItem))
    2723             :     {
    2724           0 :         boost::scoped_ptr<TargetList> pList(new TargetList);
    2725           0 :         ((const SfxFrameItem*)pItem)->GetFrame()->GetTargetList(*pList);
    2726           0 :         if( !pList->empty() )
    2727             :         {
    2728           0 :             size_t nCount = pList->size();
    2729           0 :             for ( size_t i = 0; i < nCount; i++ )
    2730             :             {
    2731           0 :                 pFrameCB->InsertEntry( pList->at( i ) );
    2732             :             }
    2733           0 :         }
    2734             :     }
    2735             : 
    2736           0 :     if ( SfxItemState::SET == rSet->GetItemState( RES_URL, true, &pItem ) )
    2737             :     {
    2738           0 :         const SwFmtURL* pFmtURL = (const SwFmtURL*)pItem;
    2739             :         pURLED->SetText( INetURLObject::decode( pFmtURL->GetURL(),
    2740             :                                         '%',
    2741             :                                            INetURLObject::DECODE_UNAMBIGUOUS,
    2742           0 :                                         RTL_TEXTENCODING_UTF8 ));
    2743           0 :         pNameED->SetText( pFmtURL->GetName());
    2744             : 
    2745           0 :         pClientCB->Enable( pFmtURL->GetMap() != 0 );
    2746           0 :         pClientCB->Check ( pFmtURL->GetMap() != 0 );
    2747           0 :         pServerCB->Check ( pFmtURL->IsServerMap() );
    2748             : 
    2749           0 :         pFrameCB->SetText(pFmtURL->GetTargetFrameName());
    2750           0 :         pFrameCB->SaveValue();
    2751             :     }
    2752             :     else
    2753           0 :         pClientCB->Enable( false );
    2754             : 
    2755           0 :     pServerCB->SaveValue();
    2756           0 :     pClientCB->SaveValue();
    2757           0 : }
    2758             : 
    2759           0 : bool SwFrmURLPage::FillItemSet(SfxItemSet *rSet)
    2760             : {
    2761           0 :     bool bModified = false;
    2762           0 :     const SwFmtURL* pOldURL = (SwFmtURL*)GetOldItem(*rSet, RES_URL);
    2763           0 :     boost::scoped_ptr<SwFmtURL> pFmtURL;
    2764           0 :     if(pOldURL)
    2765           0 :         pFmtURL.reset((SwFmtURL*)pOldURL->Clone());
    2766             :     else
    2767           0 :         pFmtURL.reset(new SwFmtURL());
    2768             : 
    2769             :     {
    2770           0 :         const OUString sText = pURLED->GetText();
    2771             : 
    2772           0 :         if( pFmtURL->GetURL() != sText ||
    2773           0 :             pFmtURL->GetName() != pNameED->GetText() ||
    2774           0 :             pServerCB->IsChecked() != pFmtURL->IsServerMap() )
    2775             :         {
    2776           0 :             pFmtURL->SetURL( sText, pServerCB->IsChecked() );
    2777           0 :             pFmtURL->SetName( pNameED->GetText() );
    2778           0 :             bModified = true;
    2779           0 :         }
    2780             :     }
    2781             : 
    2782           0 :     if(!pClientCB->IsChecked() && pFmtURL->GetMap() != 0)
    2783             :     {
    2784           0 :         pFmtURL->SetMap(0);
    2785           0 :         bModified = true;
    2786             :     }
    2787             : 
    2788           0 :     if(pFmtURL->GetTargetFrameName() != pFrameCB->GetText())
    2789             :     {
    2790           0 :         pFmtURL->SetTargetFrameName(pFrameCB->GetText());
    2791           0 :         bModified = true;
    2792             :     }
    2793           0 :     rSet->Put(*pFmtURL);
    2794           0 :     return bModified;
    2795             : }
    2796             : 
    2797           0 : SfxTabPage* SwFrmURLPage::Create(vcl::Window *pParent, const SfxItemSet *rSet)
    2798             : {
    2799           0 :     return new SwFrmURLPage( pParent, *rSet );
    2800             : }
    2801             : 
    2802           0 : IMPL_LINK_NOARG(SwFrmURLPage, InsertFileHdl)
    2803             : {
    2804           0 :     FileDialogHelper aDlgHelper( ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 );
    2805           0 :     uno::Reference < ui::dialogs::XFilePicker > xFP = aDlgHelper.GetFilePicker();
    2806             : 
    2807             :     try
    2808             :     {
    2809           0 :         const OUString sTemp(pURLED->GetText());
    2810           0 :         if(!sTemp.isEmpty())
    2811           0 :             xFP->setDisplayDirectory(sTemp);
    2812             :     }
    2813           0 :     catch( const uno::Exception& rEx )
    2814             :     {
    2815             :         (void) rEx;
    2816             :     }
    2817           0 :     if( aDlgHelper.Execute() == ERRCODE_NONE )
    2818             :     {
    2819           0 :         pURLED->SetText( xFP->getFiles().getConstArray()[0] );
    2820             :     }
    2821             : 
    2822           0 :     return 0;
    2823             : }
    2824             : 
    2825           0 : SwFrmAddPage::SwFrmAddPage(vcl::Window *pParent, const SfxItemSet &rSet)
    2826             :     : SfxTabPage(pParent, "FrmAddPage" , "modules/swriter/ui/frmaddpage.ui", &rSet)
    2827             :     , pWrtSh(0)
    2828             :     , bHtmlMode(false)
    2829             :     , bFormat(false)
    2830           0 :     , bNew(false)
    2831             : {
    2832           0 :     get(pNameFrame, "nameframe");
    2833           0 :     get(pNameFT,"name_label");
    2834           0 :     get(pNameED,"name");
    2835           0 :     get(pAltNameFT,"altname_label");
    2836           0 :     get(pAltNameED,"altname");
    2837           0 :     get(pPrevFT,"prev_label");
    2838           0 :     get(pPrevLB,"prev");
    2839           0 :     get(pNextFT,"next_label");
    2840           0 :     get(pNextLB,"next");
    2841             : 
    2842           0 :     get(pProtectFrame,"protect");
    2843           0 :     get(pProtectContentCB,"protectcontent");
    2844           0 :     get(pProtectFrameCB,"protectframe");
    2845           0 :     get(pProtectSizeCB,"protectsize");
    2846             : 
    2847           0 :     get(m_pContentAlignFrame, "contentalign");
    2848           0 :     get(m_pVertAlignLB,"vertalign");
    2849             : 
    2850           0 :     get(pPropertiesFrame,"properties");
    2851           0 :     get(pEditInReadonlyCB,"editinreadonly");
    2852           0 :     get(pPrintFrameCB,"printframe");
    2853           0 :     get(pTextFlowFT,"textflow_label");
    2854           0 :     get(pTextFlowLB,"textflow");
    2855             : 
    2856           0 : }
    2857             : 
    2858           0 : SwFrmAddPage::~SwFrmAddPage()
    2859             : {
    2860           0 : }
    2861             : 
    2862           0 : SfxTabPage* SwFrmAddPage::Create(vcl::Window *pParent, const SfxItemSet *rSet)
    2863             : {
    2864           0 :     return new SwFrmAddPage(pParent, *rSet);
    2865             : }
    2866             : 
    2867           0 : void SwFrmAddPage::Reset(const SfxItemSet *rSet )
    2868             : {
    2869             :     const SfxPoolItem* pItem;
    2870           0 :     sal_uInt16 nHtmlMode = ::GetHtmlMode((const SwDocShell*)SfxObjectShell::Current());
    2871           0 :     bHtmlMode = nHtmlMode & HTMLMODE_ON ? sal_True : sal_False;
    2872           0 :     if (bHtmlMode)
    2873             :     {
    2874           0 :         pProtectFrame->Hide();
    2875           0 :         pEditInReadonlyCB->Hide();
    2876           0 :         pPrintFrameCB->Hide();
    2877             :     }
    2878           0 :     if (sDlgType == "PictureDialog" || sDlgType == "ObjectDialog")
    2879             :     {
    2880           0 :         pEditInReadonlyCB->Hide();
    2881           0 :         if (bHtmlMode)
    2882             :         {
    2883           0 :             pPropertiesFrame->Hide();
    2884             :         }
    2885           0 :         m_pContentAlignFrame->Hide();
    2886             :     }
    2887             : 
    2888           0 :     if(SfxItemState::SET == rSet->GetItemState(FN_SET_FRM_ALT_NAME, false, &pItem))
    2889             :     {
    2890           0 :         pAltNameED->SetText(((const SfxStringItem*)pItem)->GetValue());
    2891           0 :         pAltNameED->SaveValue();
    2892             :     }
    2893             : 
    2894           0 :     if(!bFormat)
    2895             :     {
    2896             :         // insert graphic - properties
    2897             :         // bNew is not set, so recognise by selection
    2898           0 :         OUString aTmpName1;
    2899           0 :         if(SfxItemState::SET == rSet->GetItemState(FN_SET_FRM_NAME, false, &pItem))
    2900             :         {
    2901           0 :             aTmpName1 = ((const SfxStringItem*)pItem)->GetValue();
    2902             :         }
    2903             : 
    2904             :         OSL_ENSURE(pWrtSh, "keine Shell?");
    2905           0 :         if( bNew || aTmpName1.isEmpty() )
    2906             :         {
    2907           0 :             if (sDlgType == "PictureDialog")
    2908           0 :                 aTmpName1 = pWrtSh->GetUniqueGrfName();
    2909           0 :             else if (sDlgType == "ObjectDialog")
    2910           0 :                 aTmpName1 = pWrtSh->GetUniqueOLEName();
    2911             :             else
    2912           0 :                 aTmpName1 = pWrtSh->GetUniqueFrameName();
    2913             :         }
    2914             : 
    2915           0 :         pNameED->SetText( aTmpName1 );
    2916           0 :         pNameED->SaveValue();
    2917             :     }
    2918             :     else
    2919             :     {
    2920           0 :         pNameED->Enable( false );
    2921           0 :         pAltNameED->Enable(false);
    2922           0 :         pNameFT->Enable( false );
    2923           0 :         pAltNameFT->Enable(false);
    2924             :     }
    2925           0 :     if (sDlgType == "FrameDialog" && pAltNameFT->IsVisible())
    2926             :     {
    2927           0 :         pAltNameFT->Hide();
    2928           0 :         pAltNameED->Hide();
    2929             :     }
    2930             :     else
    2931             :     {
    2932           0 :         pNameED->SetModifyHdl(LINK(this, SwFrmAddPage, EditModifyHdl));
    2933             :     }
    2934             : 
    2935           0 :     if (!bNew)
    2936             :     {
    2937           0 :         SwFrmFmt* pFmt = pWrtSh->GetFlyFrmFmt();
    2938             : 
    2939           0 :         if (pFmt)
    2940             :         {
    2941           0 :             const SwFmtChain &rChain = pFmt->GetChain();
    2942             :             const SwFlyFrmFmt* pFlyFmt;
    2943           0 :             OUString sNextChain, sPrevChain;
    2944           0 :             if ((pFlyFmt = rChain.GetPrev()) != 0)
    2945             :             {
    2946           0 :                 sPrevChain = pFlyFmt->GetName();
    2947             :             }
    2948             : 
    2949           0 :             if ((pFlyFmt = rChain.GetNext()) != 0)
    2950             :             {
    2951           0 :                 sNextChain = pFlyFmt->GetName();
    2952             :             }
    2953             :             //determine chainable frames
    2954           0 :             ::std::vector< OUString > aPrevPageFrames;
    2955           0 :             ::std::vector< OUString > aThisPageFrames;
    2956           0 :             ::std::vector< OUString > aNextPageFrames;
    2957           0 :             ::std::vector< OUString > aRemainFrames;
    2958             :             pWrtSh->GetConnectableFrmFmts(*pFmt, sNextChain, false,
    2959           0 :                             aPrevPageFrames, aThisPageFrames, aNextPageFrames, aRemainFrames );
    2960           0 :             lcl_InsertVectors(*pPrevLB, aPrevPageFrames, aThisPageFrames, aNextPageFrames, aRemainFrames);
    2961           0 :             if(!sPrevChain.isEmpty())
    2962             :             {
    2963           0 :                 if(LISTBOX_ENTRY_NOTFOUND == pPrevLB->GetEntryPos(sPrevChain))
    2964           0 :                     pPrevLB->InsertEntry(sPrevChain, 1);
    2965           0 :                 pPrevLB->SelectEntry(sPrevChain);
    2966             :             }
    2967             :             else
    2968           0 :                 pPrevLB->SelectEntryPos(0);
    2969           0 :             aPrevPageFrames.erase(aPrevPageFrames.begin(), aPrevPageFrames.end());
    2970           0 :             aNextPageFrames.erase(aNextPageFrames.begin(), aNextPageFrames.end());
    2971           0 :             aThisPageFrames.erase(aThisPageFrames.begin(), aThisPageFrames.end());
    2972           0 :             aRemainFrames.erase(aRemainFrames.begin(), aRemainFrames.end());
    2973             : 
    2974             :             pWrtSh->GetConnectableFrmFmts(*pFmt, sPrevChain, true,
    2975           0 :                             aPrevPageFrames, aThisPageFrames, aNextPageFrames, aRemainFrames );
    2976           0 :             lcl_InsertVectors(*pNextLB, aPrevPageFrames, aThisPageFrames, aNextPageFrames, aRemainFrames);
    2977           0 :             if(!sNextChain.isEmpty())
    2978             :             {
    2979           0 :                 if(LISTBOX_ENTRY_NOTFOUND == pNextLB->GetEntryPos(sNextChain))
    2980           0 :                     pNextLB->InsertEntry(sNextChain, 1);
    2981           0 :                 pNextLB->SelectEntry(sNextChain);
    2982             :             }
    2983             :             else
    2984           0 :                 pNextLB->SelectEntryPos(0);
    2985           0 :             Link aLink(LINK(this, SwFrmAddPage, ChainModifyHdl));
    2986           0 :             pPrevLB->SetSelectHdl(aLink);
    2987           0 :             pNextLB->SetSelectHdl(aLink);
    2988             :         }
    2989             :     }
    2990             :     // Pos Protected
    2991           0 :     const SvxProtectItem& rProt = (const SvxProtectItem& )rSet->Get(RES_PROTECT);
    2992           0 :     pProtectFrameCB->Check(rProt.IsPosProtected());
    2993           0 :     pProtectContentCB->Check(rProt.IsCntntProtected());
    2994           0 :     pProtectSizeCB->Check(rProt.IsSizeProtected());
    2995             : 
    2996           0 :     const SwFmtEditInReadonly& rEdit = (const SwFmtEditInReadonly& )rSet->Get(RES_EDIT_IN_READONLY);
    2997           0 :     pEditInReadonlyCB->Check(rEdit.GetValue());          pEditInReadonlyCB->SaveValue();
    2998             : 
    2999             :     // print
    3000           0 :     const SvxPrintItem& rPrt = (const SvxPrintItem&)rSet->Get(RES_PRINT);
    3001           0 :     pPrintFrameCB->Check(rPrt.GetValue());               pPrintFrameCB->SaveValue();
    3002             : 
    3003             :     // textflow
    3004             :     SfxItemState eState;
    3005           0 :     if( (!bHtmlMode || (0 != (nHtmlMode&HTMLMODE_SOME_STYLES)))
    3006           0 :             && sDlgType != "PictureDialog" && sDlgType != "ObjectDialog" &&
    3007             :         SfxItemState::UNKNOWN != ( eState = rSet->GetItemState(
    3008             :                                         RES_FRAMEDIR, true )) )
    3009             :     {
    3010           0 :         pTextFlowFT->Show();
    3011           0 :         pTextFlowLB->Show();
    3012             : 
    3013             :         //vertical text flow is not possible in HTML
    3014           0 :         if(bHtmlMode)
    3015             :         {
    3016           0 :             sal_uLong nData = FRMDIR_VERT_TOP_RIGHT;
    3017           0 :             pTextFlowLB->RemoveEntry(pTextFlowLB->GetEntryPos((void*)nData));
    3018             :         }
    3019           0 :         sal_uInt16 nVal = ((SvxFrameDirectionItem&)rSet->Get(RES_FRAMEDIR)).GetValue();
    3020             :         sal_Int32 nPos;
    3021           0 :         for( nPos = pTextFlowLB->GetEntryCount(); nPos; )
    3022           0 :             if( (sal_uInt16)(sal_IntPtr)pTextFlowLB->GetEntryData( --nPos ) == nVal )
    3023           0 :                 break;
    3024           0 :         pTextFlowLB->SelectEntryPos( nPos );
    3025           0 :         pTextFlowLB->SaveValue();
    3026             :     }
    3027             :     else
    3028             :     {
    3029           0 :         pTextFlowFT->Hide();
    3030           0 :         pTextFlowLB->Hide();
    3031             :     }
    3032             : 
    3033             :     // Content alignment
    3034           0 :     if ( rSet->GetItemState(RES_TEXT_VERT_ADJUST) > SfxItemState::DEFAULT )
    3035             :     {
    3036           0 :         SdrTextVertAdjust nAdjust = ((const SdrTextVertAdjustItem&)rSet->Get(RES_TEXT_VERT_ADJUST)).GetValue();
    3037           0 :         sal_Int32 nPos = 0;
    3038           0 :         switch(nAdjust)
    3039             :         {
    3040           0 :             case SDRTEXTVERTADJUST_TOP:      nPos = 0;   break;
    3041             :             case SDRTEXTVERTADJUST_CENTER:
    3042           0 :             case SDRTEXTVERTADJUST_BLOCK:    nPos = 1;   break;
    3043           0 :             case SDRTEXTVERTADJUST_BOTTOM:   nPos = 2;   break;
    3044             :         }
    3045           0 :         m_pVertAlignLB->SelectEntryPos(nPos);
    3046             :     }
    3047           0 :     m_pVertAlignLB->SaveValue();
    3048           0 : }
    3049             : 
    3050           0 : bool SwFrmAddPage::FillItemSet(SfxItemSet *rSet)
    3051             : {
    3052           0 :     bool bRet = false;
    3053           0 :     if (pNameED->IsValueChangedFromSaved())
    3054           0 :         bRet |= 0 != rSet->Put(SfxStringItem(FN_SET_FRM_NAME, pNameED->GetText()));
    3055           0 :     if (pAltNameED->IsValueChangedFromSaved())
    3056           0 :         bRet |= 0 != rSet->Put(SfxStringItem(FN_SET_FRM_ALT_NAME, pAltNameED->GetText()));
    3057             : 
    3058             :     const SfxPoolItem* pOldItem;
    3059           0 :     SvxProtectItem aProt ( (const SvxProtectItem& )GetItemSet().Get(RES_PROTECT) );
    3060           0 :     aProt.SetCntntProtect( pProtectContentCB->IsChecked() );
    3061           0 :     aProt.SetSizeProtect ( pProtectSizeCB->IsChecked() );
    3062           0 :     aProt.SetPosProtect  ( pProtectFrameCB->IsChecked() );
    3063           0 :     if ( 0 == (pOldItem = GetOldItem(*rSet, FN_SET_PROTECT)) ||
    3064           0 :                 aProt != *pOldItem )
    3065           0 :         bRet |= 0 != rSet->Put( aProt);
    3066             : 
    3067           0 :     if ( pEditInReadonlyCB->IsValueChangedFromSaved() )
    3068           0 :         bRet |= 0 != rSet->Put( SwFmtEditInReadonly( RES_EDIT_IN_READONLY, pEditInReadonlyCB->IsChecked()));
    3069             : 
    3070           0 :     if ( pPrintFrameCB->IsValueChangedFromSaved() )
    3071           0 :         bRet |= 0 != rSet->Put( SvxPrintItem( RES_PRINT, pPrintFrameCB->IsChecked()));
    3072             : 
    3073             :     // textflow
    3074           0 :     if( pTextFlowLB->IsVisible() )
    3075             :     {
    3076           0 :         sal_Int32 nPos = pTextFlowLB->GetSelectEntryPos();
    3077           0 :         if( pTextFlowLB->IsValueChangedFromSaved() )
    3078             :         {
    3079           0 :             sal_uInt16 nData = (sal_uInt16)(sal_IntPtr)pTextFlowLB->GetEntryData( nPos );
    3080             :             bRet |= 0 != rSet->Put( SvxFrameDirectionItem(
    3081           0 :                                     (SvxFrameDirection)nData, RES_FRAMEDIR ));
    3082             :         }
    3083             :     }
    3084           0 :     if(pWrtSh)
    3085             :     {
    3086           0 :         const SwFrmFmt* pFmt = pWrtSh->GetFlyFrmFmt();
    3087           0 :         if (pFmt)
    3088             :         {
    3089           0 :             OUString sCurrentPrevChain, sCurrentNextChain;
    3090           0 :             if(pPrevLB->GetSelectEntryPos())
    3091           0 :                 sCurrentPrevChain = pPrevLB->GetSelectEntry();
    3092           0 :             if(pNextLB->GetSelectEntryPos())
    3093           0 :                 sCurrentNextChain = pNextLB->GetSelectEntry();
    3094           0 :             const SwFmtChain &rChain = pFmt->GetChain();
    3095             :             const SwFlyFrmFmt* pFlyFmt;
    3096           0 :             OUString sNextChain, sPrevChain;
    3097           0 :             if ((pFlyFmt = rChain.GetPrev()) != 0)
    3098           0 :                 sPrevChain = pFlyFmt->GetName();
    3099             : 
    3100           0 :             if ((pFlyFmt = rChain.GetNext()) != 0)
    3101           0 :                 sNextChain = pFlyFmt->GetName();
    3102           0 :             if(sPrevChain != sCurrentPrevChain)
    3103           0 :                 bRet |= 0 != rSet->Put(SfxStringItem(FN_PARAM_CHAIN_PREVIOUS, sCurrentPrevChain));
    3104           0 :             if(sNextChain != sCurrentNextChain)
    3105           0 :                 bRet |= 0 != rSet->Put(SfxStringItem(FN_PARAM_CHAIN_NEXT, sCurrentNextChain));
    3106             :         }
    3107             :     }
    3108             : 
    3109           0 :     if(m_pVertAlignLB->IsValueChangedFromSaved())
    3110             :     {
    3111             :         SdrTextVertAdjust nAdjust;
    3112           0 :         switch(m_pVertAlignLB->GetSelectEntryPos())
    3113             :         {
    3114             :             default:
    3115           0 :             case 0 : nAdjust = SDRTEXTVERTADJUST_TOP; break;
    3116           0 :             case 1 : nAdjust = SDRTEXTVERTADJUST_CENTER; break;
    3117           0 :             case 2 : nAdjust = SDRTEXTVERTADJUST_BOTTOM; break;
    3118             :         }
    3119           0 :         bRet |= 0 != rSet->Put(SdrTextVertAdjustItem(nAdjust, RES_TEXT_VERT_ADJUST));
    3120             :     }
    3121             : 
    3122           0 :     return bRet;
    3123             : }
    3124             : 
    3125           0 : const sal_uInt16* SwFrmAddPage::GetRanges()
    3126             : {
    3127           0 :     return aAddPgRg;
    3128             : }
    3129             : 
    3130           0 : IMPL_LINK_NOARG(SwFrmAddPage, EditModifyHdl)
    3131             : {
    3132           0 :     bool bEnable = !pNameED->GetText().isEmpty();
    3133           0 :     pAltNameED->Enable(bEnable);
    3134           0 :     pAltNameFT->Enable(bEnable);
    3135             : 
    3136           0 :     return 0;
    3137             : }
    3138             : 
    3139           0 : void SwFrmAddPage::SetFormatUsed(bool bFmt)
    3140             : {
    3141           0 :     bFormat = bFmt;
    3142           0 :     if (bFormat)
    3143             :     {
    3144           0 :         pNameFrame->Hide();
    3145             :     }
    3146           0 : }
    3147             : 
    3148           0 : IMPL_LINK(SwFrmAddPage, ChainModifyHdl, ListBox*, pBox)
    3149             : {
    3150           0 :     OUString sCurrentPrevChain, sCurrentNextChain;
    3151           0 :     if(pPrevLB->GetSelectEntryPos())
    3152           0 :         sCurrentPrevChain = pPrevLB->GetSelectEntry();
    3153           0 :     if(pNextLB->GetSelectEntryPos())
    3154           0 :         sCurrentNextChain = pNextLB->GetSelectEntry();
    3155           0 :     SwFrmFmt* pFmt = pWrtSh->GetFlyFrmFmt();
    3156           0 :     if (pFmt)
    3157             :     {
    3158           0 :         bool bNextBox = pNextLB == pBox;
    3159           0 :         ListBox& rChangeLB = bNextBox ? *pPrevLB : *pNextLB;
    3160           0 :         for(sal_Int32 nEntry = rChangeLB.GetEntryCount(); nEntry > 1; nEntry--)
    3161           0 :             rChangeLB.RemoveEntry(nEntry - 1);
    3162             :         //determine chainable frames
    3163           0 :         ::std::vector< OUString > aPrevPageFrames;
    3164           0 :         ::std::vector< OUString > aThisPageFrames;
    3165           0 :         ::std::vector< OUString > aNextPageFrames;
    3166           0 :         ::std::vector< OUString > aRemainFrames;
    3167           0 :         pWrtSh->GetConnectableFrmFmts(*pFmt, bNextBox ? sCurrentNextChain : sCurrentPrevChain, !bNextBox,
    3168           0 :                         aPrevPageFrames, aThisPageFrames, aNextPageFrames, aRemainFrames );
    3169             :         lcl_InsertVectors(rChangeLB,
    3170           0 :                 aPrevPageFrames, aThisPageFrames, aNextPageFrames, aRemainFrames);
    3171           0 :         const OUString sToSelect = bNextBox ? sCurrentPrevChain : sCurrentNextChain;
    3172           0 :         if(rChangeLB.GetEntryPos(sToSelect) != LISTBOX_ENTRY_NOTFOUND)
    3173           0 :             rChangeLB.SelectEntry(sToSelect);
    3174             :         else
    3175           0 :             rChangeLB.SelectEntryPos(0);
    3176             : 
    3177             :     }
    3178           0 :     return 0;
    3179           0 : }
    3180             : 
    3181             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10