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

Generated by: LCOV version 1.10